PDA

View Full Version : mistake in Ext.Template?



695w
23 Oct 2009, 10:12 PM
1. the method append does not work in ie when i append a "option" tag to a "select" tag
append( Mixed el, Object/Array values, [Boolean returnElement] )
var tpl=new Ext.Template('<option value="{value}"> {text}</option>');
tpl.append("the select tag id",{value:'a',text:'b'});
2.sometime the template created by method Template.from does not work
eg:
html:
<div id="target_el">
</div>
<div style="display:none">
<div id='tpl'> <a href="{href}" title="{title}"> {text}</a></div>
</div>
javascript:
var str='<a href="{href}" title="{title}"> {text}</a>';
var tpl_=new Template(str);
var tpl =Ext.Template.from('tpl');
tpl_.append("target_el",{href:'a.jsp',title:'test',text:'aaaaa'});
tpl.append("target_el",{href:'a.jsp',title:'test',text:'aaaaa'});

result:
<div id="target_el">
<a href="a.jsp" title="test"> aaaaa</a>
<a href="{href}" title="test"> aaaaa</a>
</div>
forgive me and my poor english.

Condor
23 Oct 2009, 11:12 PM
1. IE doesn't support adding select options through DOM manipulation (you'll have to create Option instances and add() them to the options property, see here (http://www.extjs.com/forum/showthread.php?t=1902)).

2. from() only works if your template doesn't contain text that gets corrupted by the browser. It's recommended to use a TEXTAREA as the root element, because browsers don't corrupt a TEXTAREA value.

695w
24 Oct 2009, 4:41 AM
thank you!