简体   繁体   English

jTemplate中的Textarea在Chrome中不起作用

[英]Textarea in jTemplate does not work in Chrome

I have a template which consists textarea inside template. 我有一个模板,其中包含textarea模板。 In IE, Firefox browsers, it is working fine but in Chrome it is not working. 在IE,Firefox浏览器中,它运行正常,但在Chrome中,则无法运行。 If I remove textarea inside the template, then it's working in Chrome as well. 如果我删除模板中的textarea,则它也可以在Chrome浏览器中使用。 Can any one help me? 谁能帮我?

Exactly the same problem occurs now in Firefox 4. 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 eg test_tmpl.txt例如

<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 用jTemplates 0.7.8,jQ 1.4.2测试

I've found a workaround for this problem. 我找到了解决此问题的方法。 You can kind of "escape" textarea tag in your jtemplate with following construction: 您可以通过以下构造在jtemplate中使用“转义” textarea标记:

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

Stumbled upon the same problem. 偶然发现了同样的问题。 Current solution (found in JTemplate changelog) is to use CDATA way to style your templates 当前的解决方案(在JTemplate changelog中找到)是使用CDATA方式来设置模板样式

<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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM