0

I am using ExtJS to apply a set of data from a AJAx call to an Ext.Template. One of the elements is an array of strings.

var data = {
  name: "I am Here!",
  messages: ['aaa', 'bbb', 'ccc', 'ddd']
};

I've defined the template like this

var tpl = new Ext.Template(
  '<h2>{name}</h2>',
  '<tpl for="{messages}">',
    '<p>{.}</p>',
  '</tpl>'
);

When I apply this template to the data, it shows the {.} literally instead of printing each element. Most of the searches I have done for using arrays in in ExtJS use this format. Here is the JFiddle http://jsfiddle.net/u4zkM/2/

What is wrong with the way I am trying to use the array?

1 Answer 1

2

For arrays and other advanced functionality you need to use Ext.XTemplate. Also remove the brackets around messages.

var tpl = new Ext.XTemplate(
    '<h2>{name}</h2>',
    '<tpl for="messages">',
        '<p>{.}</p>',
    '</tpl>'
);

jsFiddle

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.