How does this backbone view get it's EL property set?
I'm looking at this Backbone app:
https://github.com/ccoenraets/nodecellar/blob/master/public/js/main.js
and trying to understand how it works. I see that in the main.js file he
calls a WineView like this:
wineList.fetch({success: function(){
$("#content").html(new WineListView({model: wineList, page:
p}).el);
I have a few questions about this:
1) Why call $("#content").... from this point? Isn't one of the points of
creating a view object to let that new objects "Render" method handle the
HTML injection? In fact his Wine View Object DOES have a render method
(here: /public/js/views/winelist.js) so what's this call here good for?
2) Why add the EL property at the end? I thought EL was simply a single
tag that the View was "attached" to. If it's just a single tag how does it
then generate all the new HTML he's looking for?
3) How does the EL tag even get set in the new view object in th first
place? I thought if you didn't explicitly state it then EL defaulted to an
empty DIV and I can see nowhere EL defined for this View in his code.
Hope someone can clear this up!
No comments:
Post a Comment