문제

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 the 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()

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top