似乎我在 jquery 模板中调用 javascript 函数时遇到了一些问题。我在这里设置了一个演示:http: //jsfiddle.net/SXvsZ/8/
代码如下:
function htmlDetail(){
return "hello <strong>world</strong>";
}
var book = [
{ title: "Goodnight, World!",
detail: { author: "Jojo Mojo", synopsis : "What the ..." }},
{ title: "Rainbow",
detail: { author: "Cookie", synopsis : "Huh?" }}
];
$("#testTemplate").tmpl(book).appendTo("#bookList");
模板看起来像:
<script id="testTemplate" type="text/x-jquery-tmpl">
{{if title.length}}
<h3>${title}</h3>
<p>Start: ${ htmlDetail() } :End</p>
{{/if}}
</script>
<div id="bookList"></div>
似乎它应该呈现“hello world ” 我想让它也将 HTML 呈现为 html 而不是纯文本。