Reputation: 8042
I am using Backbone.js and I am looking for something to turn my data into hidden elements on a form to submit and also to turn the data into values on textboxes.
I want something "battle hardened" that handles all special characters on String data and also handles numbers correctly.
Does anyone have anything like that?
Upvotes: 1
Views: 87
Reputation: 1145
To ensure that you can write out special characters, you can use .escape which is a wrapper for underscore to write values to the hidden fields. It'll convert your special characters to HTML entities. It's also useful for preventing XSS attacks. Or you can use $().text() and that will escape everything.
Upvotes: 1