3 ms·
jamesjyu: If you haven't seen Backbone.Model's "escape" method yet, it can help sanitize your model attributes, without having to constantly re-escape them at e
by jashkenas 16y ago
jamesjyu: If you haven't seen Backbone.Model's "escape" method yet, it can help sanitize your model attributes, without having to constantly re-escape them at every use.
http://documentcloud.github.com/backbone/#Model-escape http://documentcloud.github.com/backbone/#Model-escape
- bricestacey 16y agoDoes rendering attributes using jQuery's text() method[1] properly sanitize the model attributes too? I ask because I'm making a backbone app and I'm following the same process found in Ben Nolan's mobile app [2] where he does something like this.el.find('h1').text("Editing " + (this.model.getName())); [1] http://api.jquery.com/text/ [2] https://github.com/bnolan/Backbone-Mobile/blob/master/application.js
- jashkenas 16y agoYes. jQuery's text() method will properly escape HTML fragments. It's just a bit more verbose and a bit slower than using .escape("attribute") within a template.