1. #1
    Sencha User
    Join Date
    Jun 2010
    Posts
    139
    Vote Rating
    3
    jeanluca is on a distinguished road

      0  

    Default How to include my XTemplate classes

    How to include my XTemplate classes


    Hi

    To have my html a bit seperated from the rest, I have created in the app/view directory a 'template' directory. In here I have a file called SearchListItem.js:

    Code:
    Ext.define('My.view.template.SearchListItem', {
        extend: 'Ext.XTemplate',
        
        constructor: function (config) {               
        	this.callParent(['<div style="padding-left: 20px;">',
        	                        	'<div style="width:100%;float:left;position:relative">{label}</div>',
        	                          	'<img src="{icon}" style="float:left;position:relative;width:20px;right:20px;margin-left:-100%;height:20px;" />',
        	                          '</div>'] 
        	                          );
        }
    }) ;
    Now in app/view I have a list defined in SearchView.js as follows

    Code:
    Ext.define('My.view.SearchView', {
        extend: 'Ext.dataview.List',
        xtype: 'mylist',
        requires: [
            'My.view.template.SearchListItem',
            'Ext.plugin.PullRefresh',
            'Ext.plugin.ListPaging'
        ],
    
        config: {
            itemTpl: new My.view.template.SearchListItem(),
            loadingText : 'Loading...',
            ....
    As you can see, in the list I have required the SearchListItem. Unfortunately, this doesn't work and in the browser I get the error

    Uncaught TypeError: Cannot read property 'template' of undefined
    Now, when I add the require statement to app.js it works. Can someone explain to me why it doesn't work in the first place ? Should I define the template directory somewhere too ?

    Thanks a lot
    Luca

  2. #2
    Sencha User
    Join Date
    Apr 2010
    Location
    China
    Posts
    227
    Vote Rating
    20
    haduki will become famous soon enough haduki will become famous soon enough

      0  

    Default


    Code:
    new My.view.template.SearchListItem()
    should be
    Code:
      Ext.create('My.view.template.SearchListItem',{})

  3. #3
    Sencha User
    Join Date
    Jun 2010
    Posts
    139
    Vote Rating
    3
    jeanluca is on a distinguished road

      0  

    Default


    thanks, thats it!!

Thread Participants: 1

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi