0
votes

i am a beginner in sencha touch, i am trying to run a demo application using sencha touch profiles this is the code

<!-- index.html-->
<!DOCTYPE html>
<html>
    <head>
       <title>MOIC Touch</title>
       <link rel="stylesheet" href="touch/resources/css/sencha-touch.css" type="text/css">
       <script type="text/javascript" src="touch/sencha-touch-all-debug.js"></script>
       <script type="text/javascript" src="app.js"></script>
    </head>
    <body></body>
</html>

//app.js
Ext.require([
     'MOICTouch.profile.Tablet']);
Ext.application({
    name: 'MOICTouch',
    profiles: ['Tablet']
});


//app/profile/Tablet.js
Ext.define('MOICTouch.profile.Tablet', {
      extend: 'Ext.app.Profile',

      config: {
         name: 'Tablet',
         views: ['Main']
      },

      isActive: function() {
         return Ext.os.is.Tablet;
      }
 });

when i run index.html i got the following error in browser console

Uncaught Error: Ext.Loader is not enabled, so dependencies cannot be resolved dynamically. Missing required class: MOICTouch.profile.Tablet

can anyone help me, thanks in advance

1
the solution is enabling Ext.loader to resolve the used classes dynamically and you can do that by adding the following code snippet at the beginning of app.js file Ext.Loader.setConfig({enabled:true}); - aomar

1 Answers

0
votes

As you mentioned, you should enable Ext.Loader using the following code:

Ext.Loader.setConfig({ enabled: true });

However, this only happens because you are including sencha-touch-all-debug.js. The file includes the whole framework, so it presumes you do not need to use the Loader.

In development, you should use sencha-touch-debug.js. This will enable Ext.Loader by default, and will actually dynamically load each of the classes you require in the framework - instead of loading the whole framework up front.

There is more information about the different builds, and how to build your application for production over on the Sencha Touch API Docs - http://docs.sencha.com/touch/2-0/#!/guide/building