Results 1 to 3 of 3

Thread: Template breaks when calling function

    Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1

    Default Template breaks when calling function

    REQUIRED INFORMATION

    Ext version tested:
    • Ext 4.2.0
    Browser versions tested against:
    • Chrome
    Description:
    • When defining a template that loops trough array of records adding a function to it will break the template if "values." is not added before attribute name that you are trying to pass to the function
    Test Case:

    If I define template like this it will render just fine
    Code:
    '<span class="title">Record</span>' +
    '<tpl for="data">' +
    '<span>{name}</span>' +
    '<span>{[call.some.function.here(country)]}</span>' +
    '</tpl>'
    but when I try to loop trough more than one record it won't work
    Code:
    '<span class="title">Records</span>' +
    '<tpl for=".">' +
    '<tpl for="data">' +
    '<span>{name}</span>' +
    '<span>{[call.some.function.here(country)]}</span>' + <---method does not get called and it stops rendering further records
    '</tpl></tpl>'
    and in order to get it working I have to do this:
    Code:
    '<span class="title">Records</span>' +
    '<tpl for=".">' +
    '<tpl for="data">' +
    '<span>{name}</span>' +
    '<span>{[call.some.function.here(values.country)]}</span>' +
    '</tpl></tpl>'

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,448

    Default

    So it breaks when you try to pass country to the function but works when you pass values.country? This is expected behavior as when you do {[...]} you are using plain javascript which is passed the values object.
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  3. #3

    Default

    I understand, but shouldn't same apply when template isn't looping trough record array?

Posting Permissions

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