Backbone: rendering syntax
- by ksol
We're using Backbone.js in one of my team's projects, and this is the first time I use it.
I've seen many times this kind of code (it's coffeescript, but clear enough I think. @ means this.)
clients_view = new Homespa.Views.Orders.Clients.SectionView(collection: @options.clients)
@$("#clients-section").html(clients_view.render().el)
clients_search_view = new Homespa.Views.Orders.Clients.SearchView
@$("#clients_search_modal").html(clients_search_view.render().el)
Isn't there a better way to do this? I would expect to just call render on my view, and then everything's good, I shouldn't have to get the html and append/replace it by hand.
Thanks for you time !