Results 1 to 4 of 4

Thread: problem with requiring files

  1. #1
    Sencha User
    Join Date
    Jun 2010
    Posts
    139
    Vote Rating
    3
      0  

    Default Answered: problem with requiring files

    Hello

    When I run my app I get warnings like

    Code:
    [WARN][Anonymous] [Ext.Loader] Synchronously loading 'NS.view.template.SearchListItem'; consider adding NS.view.template.SearchListItem' explicitly as a require of the corresponding class
    Here is how I've used the SearchListItem:

    Code:
    Ext.define('NS.view.ItemList',
    {
        extend: 'Ext.dataview.List',
    
        requires: [ 'NS.view.template.SearchListItem'],
    
        config:
        {
            itemTpl: Ext.create('NS.view.template.SearchListItem'),
            ......
        }
    });
    The warning is only gone when I require the SearchListItem in app.js

    Any suggestions ?

    Cheers

  2. Code:
    Ext.define('NS.view.ItemList',
    {
        extend: 'Ext.dataview.List',
    
        requires: [ 'NS.view.template.SearchListItem'],
    
        config:
        {
            itemTpl: Ext.create('NS.view.template.SearchListItem'),
            ......
        }
    });
    Code in red is invalid, you should not create an instance on a config like that, only create instances within methods like (typing off top of my head):

    Code:
    Ext.define('NS.view.ItemList',
    {
        extend: 'Ext.dataview.List',
    
        requires: [ 'NS.view.template.SearchListItem'],
    
        config:
        {
            itemTpl: true,
            ......
        },
    
        applyItemTpl : function(tpl, oldTpl) {
            if (tpl === true) {
                tpl = Ext.create('NS.view.template.SearchListItem');
            }
    
            return this.callParent([tpl, oldTpl]);
        }
    });

  3. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Answers
    3931
    Vote Rating
    1272
      0  

    Default

    Code:
    Ext.define('NS.view.ItemList',
    {
        extend: 'Ext.dataview.List',
    
        requires: [ 'NS.view.template.SearchListItem'],
    
        config:
        {
            itemTpl: Ext.create('NS.view.template.SearchListItem'),
            ......
        }
    });
    Code in red is invalid, you should not create an instance on a config like that, only create instances within methods like (typing off top of my head):

    Code:
    Ext.define('NS.view.ItemList',
    {
        extend: 'Ext.dataview.List',
    
        requires: [ 'NS.view.template.SearchListItem'],
    
        config:
        {
            itemTpl: true,
            ......
        },
    
        applyItemTpl : function(tpl, oldTpl) {
            if (tpl === true) {
                tpl = Ext.create('NS.view.template.SearchListItem');
            }
    
            return this.callParent([tpl, oldTpl]);
        }
    });
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  4. #3
    Sencha User
    Join Date
    Jun 2010
    Posts
    139
    Vote Rating
    3
      0  

    Default

    ok, thanks a lot!

  5. #4
    Sencha User
    Join Date
    Jun 2010
    Posts
    139
    Vote Rating
    3
      0  

    Default

    I can't get this to work in the following situation in which I create a new field type:

    Code:
    Ext.define('NS.view.field.CField', { 
              extend: 'Ext.field.Field',
              xtype: cfield',
              config: {
                   component: {
                         xtype: 'panel',
                         tpl: 'NS.view.field.template.CfTpl'
                   }
             },
             initialize: function() {
                   this.callParent();
             },
             applyTpl: function(nv, ov) {
                    this.getComponent().setTpl(Ext.create('NS.view.field.template.CfTpl') ;
             },
             .....
    So, if create this component something like

    Code:
    {
         xtype: 'cfield',<br>
         tpl: true<br>
    }
    So, how can I set the tpl on the component ?

    cheers

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
  •