【发布时间】:2013-05-21 14:58:37
【问题描述】:
我想在下划线模板中存储一个 JSON 对象或字符串。
<script id="report_field_template" type="text/template">
<div data-options="<%= options %>" role="<%- role %>" title="<%- title %>" class="ui-widget-content ui-corner-all report_field">
<p><%- field_text %></p>
</div>
</script>
如果我将“选项”作为 JSON 字符串或 JSON 对象传递,上述方法将不起作用。有什么想法吗?
【问题讨论】:
-
我会确保您的选项中没有任何双引号。您可能还需要使用
标签: javascript jquery json templates underscore.js