Why is JSON binding inside jQuery template not parsed inside tag?
I have an upload script inside an XSL template, which lets JavaScript upload a file. It's inside an XSL template. The upload handler file (upload.php) will return开发者_JAVA百科 a JSON object when the file is uploaded.
<script id="template-download" type="text/x-jquery-tmpl">
<a href="${url}">${url}</a>
</script>
But when I see the output, only the second ${url}
is parsed.
Propably a JSON binding ${the_binding}
(which is extracted from the JSON object) won't get parsed while it's the value of an attribute.
Thus, the result is the following:
<a href="${url}">http://google.com/search?q=this+JSON+binding+is+parsed</a>
How to let the binding inside href
attribute get it's proposed value?
Here is an example of that template being rendered correctly:
$('#template-download').tmpl({url: 'http://google.com'}).appendTo('body');
If that's not working for you, then there must be something wrong in how you're rendering the template.
精彩评论