Reputation: 1216
I have a piece of javascript code as follows:
var data = { ... };
var template = "<select>" +
"<option value='${0:###,###.##}'>Format as $</option>" +
"</select>";
$.tmpl(template, data).appendTo("#placeholder");
My problem is that I want to evaluate the "value='${0:###,###.##}'" as a string, but jQuery templates attempts to evaluate it as an object reference.
Is there a way to escape the ${} characters?
Cheers, Shane
Upvotes: 3
Views: 1385
Reputation: 1296
Try to replace $ with its special HTML character $
var data = { };
var template = "<select>" +
"<option value='${0:###,###.##}'>Format as $</option>" +
"</select>";
$.tmpl( template, data).appendTo("#placeholder");
Upvotes: 5