Including html/html-like content in data attribute for child row without AJAX

Including html/html-like content in data attribute for child row without AJAX

cedportercedporter Posts: 4Questions: 2Answers: 0

Piggy-backing off the question posed here, it appears the last question in this was never answered.

If you insert escaped html or xml into a data-child-value attribute, as shown in this fiddle, it won't display in the row when it is shown.

Is there some way to disable that?

This question has an accepted answers - jump to answer

Answers

  • glendersonglenderson Posts: 231Questions: 11Answers: 29

    This will work for the example you provided.

    value = value.replace("<","&lt;").replace(">","&gt;")
    

    I'm just not sure if there are other characters that also need to be replaced.

  • cedportercedporter Posts: 4Questions: 2Answers: 0

    That doesn't get me all the way, but it did give me an idea. I found he.js. Processing the value with he.encode will disguise any troublesome entities, and let you store whatever you'd like in the value. I updated the fiddle, pasting he.js to illustrate the fix.

  • glendersonglenderson Posts: 231Questions: 11Answers: 29
    Answer ✓

    This will do just about the same, with a lot less coding.

    value = value.replace(/</g,"&lt;")
    value = value.replace(/>/g,"&gt;")
    value = value.replace(/"/g,"\"")
    
  • cedportercedporter Posts: 4Questions: 2Answers: 0

    That does work!

This discussion has been closed.