Vallabha Vamaravelli
Vallabha Vamaravelli

Reputation: 1293

Textarea in jTemplate does not work in Chrome

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?

Upvotes: 0

Views: 551

Answers (3)

ArSoron
ArSoron

Reputation: 3

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

Upvotes: 0

Vitaly
Vitaly

Reputation: 2585

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>

Upvotes: 0

Miroslav Pecka
Miroslav Pecka

Reputation: 11

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

Upvotes: 1

Related Questions