1. #1
    Sencha User
    Join Date
    Feb 2008
    Location
    Italy
    Posts
    20
    Vote Rating
    0
    BrightSoul is on a distinguished road

      0  

    Question Undefined value passed to a helper function in an XTemplate

    Undefined value passed to a helper function in an XTemplate


    Hello, this is probably a silly question but I can't figure out the syntax I should use.
    So, i have a simple template like this:

    Code:
    <tpl for=".">
        <div class="list-item">
            {title}
        </div>
    </tpl>
    The title is displayed just fine. Now I need to do something to the title before it's displayed, so I've set up an helper function as shown in this video. http://vimeo.com/16289990
    My updated template:

    Code:
    <tpl for=".">
        <div class="list-item">
            {[this.doSomething(title)]}
        </div>
    </tpl>
    When I do so, Sencha throws this error:

    Code:
    Uncaught ReferenceError: title is not defined
    Well... this.title and {title} are not working either. How should I write that line?
    Thank you.

  2. #2
    Ext JS Premium Member Steffen Hiller's Avatar
    Join Date
    Mar 2008
    Posts
    773
    Vote Rating
    28
    Steffen Hiller will become famous soon enough Steffen Hiller will become famous soon enough

      0  

    Default


    Try values.title

  3. #3
    Sencha User
    Join Date
    Feb 2008
    Location
    Italy
    Posts
    20
    Vote Rating
    0
    BrightSoul is on a distinguished road

      0  

    Thumbs up


    YES! Thank you :]

  4. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,065
    Vote Rating
    659
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    FYI, the reason you need to use values is because you're using the arbitrary code execution, since you need to call that method. If you were just embedding the value, {title} would be fine.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

Similar Threads

  1. Replies: 11
    Last Post: 3 Nov 2010, 11:05 AM
  2. XTemplate, if statement value is undefined
    By ExtSwede in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 31 Mar 2010, 5:20 AM
  3. Ext.Direct / Ext.Grid -- idProperty is being passed back as undefined
    By poopsmith in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 18 Feb 2010, 9:28 AM
  4. Understanding the arguments passed to a listener function
    By Event Horizon in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 29 May 2008, 4:40 AM
  5. checkHandler is calling passed function 2 times
    By n01champion in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 23 Feb 2007, 2:00 PM

Thread Participants: 2