PDA

View Full Version : [2.0b1][CLOSED] Bug with templates when using "Template.from" and an html input IE7



belgattitude
29 Oct 2007, 4:57 AM
Hi,

just noticed a strange (incorrect) behaviour of templates on IE7 (works well in FF) tested with latest svn (build 1336). Look at the following code :



Ext.onReady(function(){
var data = { quantity : 1 };
var p = new Ext.Panel({
title: 'Basic Template',
width: 300,
html: '<p><i>Apply the template to see results here</i></p>',
tbar: [{
text: 'Apply Template',
handler: function(){
var tpl = new Ext.Template.from('mytemplate');
tpl.overwrite(p.body, data);
}
}],
renderTo: document.body
});
});




<div id="mytemplate" class="x-hidden">
<input type="text" name="test" id="test" value="{quantity}" />
</div>


This works well, but if {quantity} is not defined, it will display 'name="test"' in the input (You can take a look to the attached screenshot to see the result). The correct behaviour should be and empty string (?)

Test it by changing the first line :

var data = { quantity : 1 };
by

var data = { otherValue : 1 };

Note that if I test the code without using Ext.Template.from(<id>) but with a Ext.Template(<html code>) it works as expected (input filled with an empty string).

Hope you'll understand ;)

Thanks for the great work !

Seb

aconran
29 Oct 2007, 7:08 AM
When using the Template's static from method you should use a textarea. Your sample works properly when using a textarea instead of a div.

belgattitude
5 Nov 2007, 8:02 AM
Thanks for the answer. But no luck... probably I was unable to make myself understandable ;)


When using the Template's static from method you should use a textarea. Your sample works properly when using a textarea instead of a div.



<div id="mytemplate" class="x-hidden">
<input type="text" name="test" id="test" value="{quantity}" />
</div>


Changing the div by a textarea is not really what I want to do. The problem comes from the <input type="text" ...> which for some strange reason is filled with tag attributes instead of blank value (only in IE7 , Safari and Firefox works well)

Hope you'll help me to find a solution...

Thanks in advance,

Seb

aconran
5 Nov 2007, 8:05 AM
For cross-browser consistency you should really use a textarea as specified by the docs.