1. #1
    Sencha User
    Join Date
    Jul 2011
    Posts
    14
    Vote Rating
    0
    mikerudra is on a distinguished road

      0  

    Default Defining and using functions in templates

    Defining and using functions in templates


    Hey guys,

    I have this situation and I cannot get it to work.
    I have a detail view opening from a list. Inside the detail view the entire data is built dynamically at itemtap.

    In onListItemTap (main controller) I tried this:

    detailView.getScheduleTemplate = function (str) {
    return "***"+str+"***"; //just to see it working
    }

    in the template of the detailView I set this
    {schedule:this.getScheduleTemplate}

    schedule is set for the giving data, I also logged the detailView and IT DOES contain the new function getScheduleTemplate... so everything should be fine. I get this tho:


    Uncaught Error: [ERROR][Ext.XTemplate#apply] Object [object Object] has no method 'getScheduleTemplate'
    Ext.define.doWritesencha-touch-all-debug.js:26157
    Ext.define.writesencha-touch-all-debug.js:18523
    Ext.define.logsencha-touch-all-debug.js:18397
    (anonymous function)sencha-touch-all-debug.js:18415
    Ext.define.applyOutsencha-touch-all-debug.js:41061
    Ext.define.applysencha-touch-all-debug.js:41042
    Ext.define.overwritesencha-touch-all-debug.js:40766
    Ext.define.updateDatasencha-touch-all-debug.js:54988
    Ext.apply.generateSetter.settersencha-touch-all-debug.js:5227
    (anonymous function)Main.js:114
    (anonymous function)Main.js:134
    Ext.apply.callbacksencha-touch-all-debug.js:9545
    Ext.define.onProxyLoadsencha-touch-all-debug.js:49261
    Ext.define.processResponsesencha-touch-all-debug.js:32372
    (anonymous function)sencha-touch-all-debug.js:32792
    Ext.apply.callbacksencha-touch-all-debug.js:9545
    Ext.define.handleResponsesencha-touch-all-debug.js:15276
    (anonymous function)sencha-touch-all-debug.js:3146
    (anonymous function)
    Please help!

  2. #2
    Sencha User
    Join Date
    Jul 2011
    Posts
    14
    Vote Rating
    0
    mikerudra is on a distinguished road

      0  

    Default The WYSIWYG editor malformated my error...

    The WYSIWYG editor malformated my error...


    Forget it.. :o)
    Found a workaround, just used a global function and called it normally:

    {[getScheduleTemplate(":o)")]}

  3. #3
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,359
    Vote Rating
    128
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    You could also add it to Ext.util.Format
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  4. #4
    Sencha User
    Join Date
    Jul 2011
    Posts
    14
    Vote Rating
    0
    mikerudra is on a distinguished road

      0  

    Default COOLIO!

    COOLIO!


    Yeah this is what I was looking for thanks!

    Rudra

Thread Participants: 1