Backbone: rendering syntax

Posted by ksol on Stack Overflow See other posts from Stack Overflow or by ksol
Published on 2012-07-06T08:45:40Z Indexed on 2012/07/06 9:15 UTC
Read the original article Hit count: 185

Filed under:
|

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 !

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about backbone.js