Results 1 to 5 of 5

Thread: Confusion over dynamic loading and referencing by alias

  1. #1
    Sencha User
    Join Date
    Jul 2013
    Posts
    3

    Default Confusion over dynamic loading and referencing by alias

    If I have the following app.js file:
    Code:
    Ext.onReady(function () {
        Ext.define('myApp.myButton', {
            extend: 'Ext.button.Button',
            alias: 'myButtonAlias',
            scale   : 'large'
        });
    
    
        Ext.create('myButtonAlias', {
            renderTo: document.body,
            text    : 'Click me'
        });
    });
    .. and my index.html contains
    HTML Code:
    <script src="ext/ext-all.js"></script>
    ... the button is correctly created. But if I change the index.html to:
    HTML Code:
    <script src="ext/ext-dev.js"></script>
    ...it doesn't work. The dynamic loader is expecting to find 'myApp.myButton' in a "myButtonAlias.js" file. Is it possible to make the dynamic loader recognize that the class is already defined and allow the button to be created by reference to the alias or class name without it attempting to load it from another file? Or is it that when ext-dev.js is used classes must be in their proper place for MVC. If so I'm not clear how I would go about creating the class via the alias rather than class name.
    Last edited by Mintz; 10 Oct 2013 at 2:47 AM. Reason: incorrect js file name

  2. #2
    Sencha User
    Join Date
    Aug 2012
    Location
    Dublin
    Posts
    72

    Default Ext.Loader

    Code:
    Ext.Loader.setConfig({enabled: true});
    Ext.Loader.setPath('Ext.ux', '../ux'); 
    Ext.require([
        'Ext.grid.*',
        'Ext.data.*',
    ]);
    Did you play with Ext.Loader ? that will automatically load classes for you when needed by the application.

    In my case, I use "widgets", when the project is not MVC, you can define as you want and name the file with any name.

    Code:
        Ext.define('SampleGrid', {
            extend: 'Ext.grid.Panel',
            alias: 'widget.grid',
            ...
    Code:
        Ext.widget('grid', {
            renderTo: 'grid'
        });
    Not sure if that may help you.

  3. #3
    Sencha User
    Join Date
    Jul 2013
    Posts
    3

    Default

    No. That's not really answering the question. As the MyButton class is defined in the app.js it doesn't need to be loaded from anywhere. It's already loaded. I'm trying to use the alias to create the button and this works if ext-all.js is used, but if ext-dev.js is used it looks for a file called 'myButtonAlias.js' because it thinks I'm using the class name. How would you create a button by alias while using ext-dev.js? Is it essential that classes are defined in the appropriate file/directory when using ext-dev.js?

  4. #4
    Sencha User
    Join Date
    Jul 2013
    Posts
    3

    Default

    bump

  5. #5
    Sencha User
    Join Date
    Sep 2011
    Posts
    574
    Answers
    59

    Default

    You need to trace into this method. However comments say, that it supports aliases. Maybe you need something like alias:'widget.myButtonAlias' (as usual for components) for it to start working?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •