After upgrading firefox to 14.0.1 jquery.tmpl started displaying '[object HTMLInputElement]' as the value of the textbox. After some debugging with firefox we found that if the property that is supplied in the template is not defined or given an empty string then it is trying to look for it in the parent scope chain until the global scope.
This is happening only when we are trying to reload the view using 'this.view' (but not during refresh or fresh template load)
For example if we have a textbox like below;
<input type="text" name="foo" id="foo" value="${foo}"/>
if 'foo' is either supplied with empty string or not supplied by the controller then it is looking to find int he global scope ie. it is triggering $('#foo') which returns input textbox object. Now this object is rendered as a value of the text box hence displaying ''[object HTMLInputElement]' as the value of the textbox.
We are seeing this behavior in the latest chrome version also.
If we change either the template property name or id of the input element so that they don't match then it is working fine.
For example
<input type="text" name="foo" id="foo1" value="${foo}"/> --> this is working
<input type="text" name="foo" id="foo" value="${foo1}"/> -->this is working
But, changing either id's or property names is an expensive operation as it requires visiting the entire application and changing the templates. It is such a huge impact as we have >200 template files.
So, I edited the function buildTmplFn on 342 in tmpl.js and changed the following code:
In buildTmplFn changed Line1 below with Line2 below:
.replace( /\$\{([^\}]*)\}/g, "{{= $1}}" ) --> Line1
.replace( /\$\{([^\}]*)\}/g, "{{= \$item\.data\.$1}}" ) -->Line2
which fixed the problem.
As this requires editing the library files (which requires maintenance during upgrade), I am just wondering if anyone out there found a solution that doesn't require overwriting the library but just requires overwriting 'buildTmplFn' function.
Thanks in Advance!