Open lincolnq opened 13 years ago
IE will create global vars for ID'd elements. If this is in IE, this will be the reason... Not a bug in tmpl. But you have to avoid have ids with the same name as data variables you are testing for. This can also break regular javascript if you test for undefined on something which has the same name as an ID for an element.
Ah, sorry - I didn't realize it was browser specific. Firefox doesn't reproduce, but Chrome does. Don't have an IE to test with.
Thanks for taking the time to submit this issue. Just wanted to let you know this plugin is no longer being actively developed or maintained by the jQuery team. See README for more info.
The below example demonstrates clearly what is going on. As far as I can tell, the evaluation of {{= errr}} in the template language searches the template data, and then searches the DOM for an element with id matching the name of the variable. I expected the variable to be undefined at this point (and therefore also fail the '{{if errr}}').
Unfortunately, after trying to debug, I have no idea why it is doing this.
I will work around it with $data.err, but this was surprising behavior that seems like a bug to me.