English 中文(简体)
jTemplate中的文本区域在Chrome中不起作用
原标题:Textarea in jTemplate does not work in Chrome

我有一个模板,它由模板内部的文本区域组成。在IE和Firefox浏览器中,它运行得很好,但在Chrome浏览器中却不起作用。如果我删除模板中的文本区域,那么它也可以在Chrome中工作。有人能帮我吗?

问题回答

同样的问题现在也出现在Firefox 4中。

解决方案是从外部文件加载模板。

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

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>

使用jTemplates 0.7.8、jQ 1.4.2进行测试

偶然发现了同样的问题。当前的解决方案(可在JTemplatechangelog中找到)是使用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>

我找到了解决这个问题的办法。您可以在您的jtemplate中使用以下构造进行“转义”textarea标记:

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




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签