Why isn't tmplItem() giving my data back?
If I开发者_JAVA技巧 had any, I'd be tearing my hair out at this one.
Basically, why isn't this bit of jQuery templating working?
http://jsfiddle.net/PTBak/1/
I've used templating before and I can't see the difference / why it's not returning the data.
This is because you are trying to access your tmplItem on something that was not generated by tmpl : the #content container. You are putting your generated content inside it and the #content element doesn't have anything to do with the generated content.
The best approach is to wrap your whole template into a single element and access that element to get the tmplItem(). In your example, I wrapped your template into a #myItem div and access this element instead because it was generated by jQuery.tmpl
http://jsfiddle.net/PTBak/3/
精彩评论