View Full Version : Javascript issue inside Ext.Xtemplate

Julius Fatherofkraken
17 Nov 2011, 12:16 AM

Extracting data from XML I want to preprocess one before sending it as a variable to template. A stackoverflow fellow pointed me to Ext.Xtemplate and that is close to do the job.

In each of my recors I have a value "coordinates" of this pattern : 2.342556,48.873802,0.000000
3 items separated with comma. I need the first and the second.

So I decided to split but It doesn't work.

My attempt so far (trying to display only one value for testing purposes)

var tpl = new Ext.XTemplate( '<div>{name}<br>{[ values.coordinates.split(',')[1] ]}</div>'

This echo nothing. If I display the [0] column of the array it displays the whole string, unsplited. This means that it didn't parse the comma.

If I split with something else it works (for example with an integer)

var tpl = new Ext.XTemplate( '<div>{name}<br>{[ values.coordinates.split(6)[1] ]}</div>'

I tried to split with the point ('.') but it throw an error ("unexpected string")

Maybe I should use a template member function but the example in the doc are not very clear for me.

Thanks for your help,


Julius Fatherofkraken
17 Nov 2011, 1:12 AM
I solved it with a double quote escape