Results 1 to 4 of 4

Thread: XTemplate and Ext.os

  1. #1
    Sencha User TopKatz's Avatar
    Join Date
    Mar 2007
    Posts
    340
    Vote Rating
    2
      0  

    Default XTemplate and Ext.os

    Hello, Im trying to present a differnt xtempalte if a device is iOS. In EXTJS I would just build the tamplate in my initComponet. I'm using MVC pattern and define and that approach is nto working. So I was playing with trying to use a function in my template. This is what I ahve, but its nto wroking.

    Code:
    Ihc.mobile.ClientTPL = new Ext.XTemplate(
                                   
                                                   '<tpl if="this.checkOS() == \'ios\'">',
                                                        '<a href="http://maps.apple.com/q={address}+{city}+{state}+{zip}" target="_blank"><div id="clAddress">{address}</div>',
    
                                                    '<tpl else>',
                                                        '<a href="http://maps.google.com/maps?f=q&hl=en&geocode=&q={address}+{city}+{state}+{zip}" target="_blank"><div id="clAddress">{address}</div>',
                                                    '</tpl>',
                                                
                                      '</div>',
                                    {
                                    checkOS:function(){
                                        if(Ext.os.is.iOS){
                                            return 'ios';
                                        }else{
                                            return 'notios'
                                        }
    
                                        }
                                    }
                                )
    Everythign comes back as notios. Any hep of other ideas would be awesome!

  2. #2
    Sencha User TopKatz's Avatar
    Join Date
    Mar 2007
    Posts
    340
    Vote Rating
    2
      1  

    Default

    This is working for those who want to know:

    Code:
    Ihc.mobile.ClientTPL = new Ext.XTemplate(
    
     '<tpl if="this.checkOS() == true">',
                                                        '<a href="http://maps.apple.com/?q={address}+{city}+{state}+{zip}" target="_blank"><div id="clAddress">{address}</div>',
    
                                                    '<tpl else>',
                                                        '<a href="http://maps.google.com/maps?f=q&hl=en&geocode=&q={address}+{city}+{state}+{zip}" target="_blank"><div id="clAddress">{address}</div>',
                                                    '</tpl>',
    {
                                    checkOS:function(){
    
                                            return Ext.os.is.iOS;
    
    
                                        }
                                    }

  3. #3
    Sencha - Support Team
    Join Date
    Oct 2011
    Posts
    4,094
    Vote Rating
    136
      0  

    Default

    Thank you for posting your solution.

  4. #4
    Sencha User jerome76's Avatar
    Join Date
    Apr 2012
    Location
    New Jersey
    Posts
    1,149
    Vote Rating
    101
      0  

    Default

    Thanks TopKatz! I like this better than actually creating a whole separate XTemplate
    Sencha Touch 2.x
    Ext.ux.MultiBadgeButton - Forum | GitHub
    Ext.field.SmallRadio - Forum | GitHub

    Ext JS 4.x
    Ext Calendar Pro - Time Indicator - Forum| GitHub

Posting Permissions

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