开发者

Binding data to DOM node rendered through jQuery templates

I’ve got a set of JSON data that I’m rendering into a set of table rows using jQuery’s new templating plugin. One of the pieces of data is a filename that I’m rendering to the table row as a data attribute:

<tr data-file="filename">

This mostly works fine when I retrieve it at a later date, but I’m getting errors that seem to be arising from unescaped apostrophes in certain file names. To work around this I’d like to move to just storing the data as a jQuery data object against th开发者_开发问答e table row in the first place and avoiding the DOM completely. Is there any way to do this in the current jQuery template plugin?


You can escape() the value to deal with apostrophes in the file names before binding the value in the data-file field, And when reading unescape()

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜