开发者

Textarea in jTemplate does not work in Chrome

开发者 https://www.devze.com 2023-01-21 19:12 出处:网络
I have a template which consists textarea inside template. In IE, Firefox browsers, it is working fine but in Chrome it is not working. If I remove textarea inside the template, then it\'s working 开发

I have a template which consists textarea inside template. In IE, Firefox browsers, it is working fine but in Chrome it is not working. If I remove textarea inside the template, then it's working 开发者_开发知识库in Chrome as well. Can any one help me?


Exactly the same problem occurs now in Firefox 4.

Solution is to load template from external file.

var template =  jQuery.createTemplateURL("/path/test_tmpl.txt");
$("#result").setTemplate(template);
$("#result").processTemplate(data);

test_tmpl.txt e.g.

<table>
    {#foreach $T.users as row}
    <tr>
            <td><textarea>{$T.row.id}</textarea></td>
            <td>{$T.row.name}</td>
            <td>{$T.row.age}</td>
    </tr>
    {#/for}
</table>

Tested with jTemplates 0.7.8, jQ 1.4.2


Stumbled upon the same problem. Current solution (found in JTemplate changelog) is to use CDATA way to style your templates

<p style="display: none">
<textarea id="template" rows="0" cols="0">**<![CDATA[**
  <form ...>
  ...
    <textarea rows="4" cols="20" name="name">{$T.Description}</textarea>
    <input type="submit" value="Save" />
  </form>
]]></textarea>
</p>


I've found a workaround for this problem. You can kind of "escape" textarea tag in your jtemplate with following construction:

<{"textarea"} rows="4" cols="20">{$T.Description}<{"/textarea"}>
0

精彩评论

暂无评论...
验证码 换一张
取 消