Question

 CODE :
 var data={"today date":'12-02-2014' ,"created date":'10-2-1014'}

   tpl= new Ext.XTemplate('<tpl for=".">','<p>{today date}</p>','<p>{created date}</p>','</tpl>');                                                

here I have attached the sample code.

Was it helpful?

Solution

Simple answer: don't.

var data = {"today date":'12-02-2014' ,"created date":'10-2-1014'};

// notice udpated variable names
var tpl = new Ext.XTemplate('<tpl for=".">','<p>{today_date}</p>','<p>{created_date}</p>','</tpl>');

var fixedData = {};
Ext.each(Ext.Object.getKeys(data), function(key) {
    fixedData[key.replace(/ /g, '_')] = data[key];
});

// test
alert(tpl.apply(fixedData));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top