1. #1
    Sencha Premium Member
    Join Date
    Oct 2011
    Location
    Duluth, MN
    Posts
    126
    Answers
    2
    Vote Rating
    4
    badgerb1 is on a distinguished road

      0  

    Default Unanswered: Base Sencha Touch with dynamic loading.

    Unanswered: Base Sencha Touch with dynamic loading.


    Hi all,

    When I try to use the sencha-touch.js instead of the sencha-touch-all.js file, the system will error when it tries to load a class by it's alias because it is trying to load it from the root instead of the loader path for sencha.

    I.E.

    Ext.Loader.setPath('Ext', 'sencha-touch/src');

    Ext.create('direct.remotingprovider', {});


    Will fail with a 404 because it tries to load

    direct/remotingprovider.js

    instead of
    sencha-touch/src/direct/RemotingProvider.js

    Thanks
    Bob

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,327
    Answers
    3540
    Vote Rating
    850
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Ext.create will accept the class name not the alias. If you want to create a component based on the xtype then you can use Ext.widget.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha Premium Member
    Join Date
    Oct 2011
    Location
    Duluth, MN
    Posts
    126
    Answers
    2
    Vote Rating
    4
    badgerb1 is on a distinguished road

      0  

    Default


    Unfortunately, the code that is breaking is in the Sencha model and direct packages.

    The one above I copied from Manager.js

    if (!provider.isProvider) {
    provider = Ext.create('direct.' + provider.type + 'provider', provider);
    }

    I got around this one by explicitly requiring the remotingprovider separately, but then there's a similar one in Model.js too. (Don't have the exac reference at hand.

    Thanks
    Bob

  4. #4
    Sencha User Jacky Nguyen's Avatar
    Join Date
    Jul 2009
    Location
    Palo Alto, California
    Posts
    469
    Answers
    24
    Vote Rating
    14
    Jacky Nguyen has a spectacular aura about Jacky Nguyen has a spectacular aura about

      0  

    Default


    Use sencha-touch-debug.js for development, then follow the warnings to add explicit requires. sencha-touch.js is for production, there's no extra pre-mapping code to aid dynamic loading.
    Sencha Touch Lead Architect

  5. #5
    Sencha Premium Member
    Join Date
    Oct 2011
    Location
    Duluth, MN
    Posts
    126
    Answers
    2
    Vote Rating
    4
    badgerb1 is on a distinguished road

      0  

    Default


    Hi Jacky,

    I think I get it, but just a note, there are no warnings about these things because when using Sencha-touch-debug.js the classes are already loaded so the aliasing works.

    It just says, 404 error loading
    direct/remotingprovider.js

    This is inside of the direct/Manager.js code not in my code that would produce the warnings with the debug.js. So technically Ext.direct.Manager should probably have the requires for remotingprovider, although I see why you wouldn't want to do that since it would wind up adding all of the providers even if you don't need them.

    I think, if the Loader would look to see if it was loading an alias and then use the main class name everything would work perfectly, and you could run with just the sencha-touch.js file which would then produce the proper warnings from within the sencha code as to what needs to be added.

    Also, wouldn't it be more developer friendly if the debug.js didn't contain the entire sencha code base so that you could see exactly what files you are using and make it easier to track through the code. As it is, when an error occurs inside of sencha-touch-debug.js, it's kind of hard to figure out what class it is in, and it bogs down debuggers because the file is so large. If instead you had the sencha-touch.js file as a debug version that dynamically loaded all the other classes, we would be able to catch these kinds of errors and be able to add the proper requires where they belong.

    Thanks
    Bob

  6. #6
    Sencha User Jacky Nguyen's Avatar
    Join Date
    Jul 2009
    Location
    Palo Alto, California
    Posts
    469
    Answers
    24
    Vote Rating
    14
    Jacky Nguyen has a spectacular aura about Jacky Nguyen has a spectacular aura about

      0  

    Default


    You're likely using sencha-touch-all-debug.js instead of sencha-touch-debug.js.

    sencha-touch-debug.js is the development version of Sencha Touch Core, and it has pre-mappings for aliases and alternateClassNames to aid development.
    Sencha Touch Lead Architect