开发者

jQuery template expression constraints

I have:

<script id="foo" type="text/x-jquery-tmpl">
  <p>${100 * parseInt(x)}</p>
</script>

When I do:

$('#foo').tmpl({'x':5}) // or '5'

I get a TypeError (undefined method).

But if I remove the parseInt or if I move the 100 to come after the parseInt, everything works!

I've been searching and everything I find says th开发者_如何学JAVAat ${} should be able to handle arbitrary expressions, but there seems to be some syntax magic/intolerance going on here.

Any explanations?


You need to do like this:

 <p>100 * parseInt(${x})</p>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜