1. #1
    Sencha User
    Join Date
    Nov 2012
    Posts
    12
    Answers
    1
    Vote Rating
    0
    RMSX is on a distinguished road

      0  

    Default Unanswered: Changes to XTemplate behaviour between 2.0.1 and 2.1

    Unanswered: Changes to XTemplate behaviour between 2.0.1 and 2.1


    I have observed a change in the behaviour of XTemplates between Sencha touch 2.0.1 and 2.1.

    Consider the following example:

    Code:
    var counter = 0;
    
    
    var _template = new Ext.XTemplate(
        '<div>',
        '<tpl for=".">',
        '<tpl switch="Name">',
        '<tpl case="One"><div>{[this.doOne(values)]}</div>',
        '<tpl case="Two"><div>{[this.doTwo(values)]}</div>',
        '</tpl></tpl>',
        '</div>',
    {
       doOne: function(values) {
          counter++;
          console.log('Running doOne ' + counter);
          return '(' + counter + ') From One: ' + values.Value;
    },
       doTwo: function(values) {
          counter++;
          console.log('Running doTwo ' + counter);
          return '(' + counter + ') From Two: ' + values.Value;
    }
    }
    );
    
    
    
    
    var testdata = [
      { Name: 'One', Value: 'Value One' },
      { Name: 'One', Value: 'Value Two' },
      { Name: 'Two', Value: 'Value Three' },
      { Name: 'One', Value: 'Value Four' },
      { Name: 'Two', Value: 'Value Five' },
      { Name: 'Two', Value: 'Value Six' }
    ];
    
    
    
    
        Ext.application({
        launch: function() {
            var thePanel = Ext.create('Ext.Panel', {
                fullscreen: true,
                html: _template.apply(testdata)
            });
          }
        });
    Sencha Touch 2.0.1
    HTML Code:
    <div>
    <div>(1) From One: Value One</div>
    <div>(2) From One: Value Two</div>
    <div>(3) From Two: Value Three</div>
    <div>(4) From One: Value Four</div>
    <div>(5) From Two: Value Five</div>
    <div>(6) From Two: Value Six</div>
    </div>
    Running doOne 1
    Running doOne 2
    Running doTwo 3
    Running doOne 4
    Running doTwo 5
    Running doTwo 6


    Sencha Touch 2.1:
    HTML Code:
    <div>
    <div>(2) From One: Value One</div>
    <div>(4) From One: Value Two</div>
    <div>(6) From Two: Value Three</div>
    <div>(8) From One: Value Four</div>
    <div>(10) From Two: Value Five</div>
    <div>(12) From Two: Value Six</div>
    </div>

    Running doOne 1
    Running doOne 2
    Running doOne 3
    Running doOne 4
    Running doTwo 5
    Running doTwo 6
    Running doOne 7
    Running doOne 8
    Running doTwo 9
    Running doTwo 10
    Running doTwo 11
    Running doTwo 12


    Is this a bug or intended behaviour?

  2. #2
    Sencha User
    Join Date
    Nov 2012
    Posts
    12
    Answers
    1
    Vote Rating
    0
    RMSX is on a distinguished road

      0  

    Default Another Example

    Another Example


    It compounds when using the template recursively: (smaller data set for this example)

    Code:
    <!DOCTYPE html> 
    <html>
    <head>
        <meta charset="utf-8"> 
        <link rel="stylesheet" type="text/css" href="st/resources/css/sencha-touch.css">
        <script type="text/javascript" src="st/sencha-touch-all-debug.js"></script>
    </head>
    <body id="thebody">
    
    
    <script type="text/javascript">
    
    
    var counter = 0;
    
    
    var _template = new Ext.XTemplate(
        '<div>',
        '<tpl for=".">',
        '<tpl switch="Name">',
        '<tpl case="One"><div>{[this.doOne(values)]}</div>',
        '<tpl case="Two"><div>{[this.doTwo(values)]}</div>',
        '</tpl>',
        '<tpl for="Children">{[this.apply(values)]}</tpl>',
        '</tpl>',
        '</div>',
    {
       doOne: function(values) {
          counter++;
          console.log('Running doOne ' + counter);
          return '(' + counter + ') From One: ' + values.Value;
    },
       doTwo: function(values) {
          counter++;
          console.log('Running doTwo ' + counter);
          return '(' + counter + ') From Two: ' + values.Value;
    }
    }
    );
    
    
    
    
    var testdata = [
      { Name: 'One', Value: 'Value One', Children: [{ Name: 'Two', Value: 'SubValueOne', Children:[]}]},
      { Name: 'One', Value: 'Value Two', Children: [] }
    ];
    
    
    
    
        Ext.application({
        launch: function() {
            var thePanel = Ext.create('Ext.Panel', {
                fullscreen: true,
                html: _template.apply(testdata)
            });
    	  }
        });
    
    
        </script>
    </body>
    </html>
    2.0.1: As I would expect...

    HTML Code:
    <div>
    <div>(1) From One: Value One</div>
    <div>
        <div>(2) From Two: SubValueOne</div>
    </div>
    <div>(3) From One: Value Two</div>
    Running doOne 1
    Running doTwo 2
    Running doOne 3

    2.1:

    HTML Code:
    <div>
    <div>(2) From One: Value One</div>
    <div>
        <div>(6) From Two: SubValueOne</div>
    </div>
    <div>(8) From One: Value Two</div>
    </div>
    Running doOne 1
    Running doOne 2
    Running doTwo 3
    Running doTwo 4
    Running doTwo 5
    Running doTwo 6
    Running doOne 7
    Running doOne 8

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