> or if you were in earnest about only needing the raw HTML from the sub-view, how about just rendering the row templates within the table template, making your render function as simple as this:
And if you want to delegate the handling of these DOM lines to sub-views (for event handling), you can instantiate them after rendering and call `View#setElement` with a row each.
Re:Backbone.js views done right
by superchris on Thursday June 14, 2012 @01:55PM
(#4112631)
I started with an approach like yours, but really wanted the ability to have a subview helper function that inserts the subview in the right place in the parent's template. In order for this to work, I need the helper function to output the subview's element but defer rendering the subview until the subview's element is in the DOM. One case I really feel I see benefit from this is in creating reusable subviews for form elements, but I wanted to choose a simpler example to show the approach. Could be the example I chose was too simple.
Re:Backbone.js views done right
by ryanisinallofus on Thursday June 14, 2012 @01:02PM
(#4112329)
"Whoa there nellie. Complexity ahoy."
Mixing metaphors? Is it a horse or a ship you are riding?
It's really hard to read the rest of your technical reasoning (which makes sense) with opening statements like that.
Aw, I'm just horsing around. You're quite right that it's dangerous to mix metaphors while showing someone the ropes.
Re:Backbone.js views done right
by ryanisinallofus on Monday June 18, 2012 @11:54PM
(#4130170)
Lol. This is the kind of shit I'm talking about. In my head jashkenas looks just like this guy when he writes like this: http://upload.wikimedia.org/wikipedia/en/thumb/7/7c/Lulz_Sec...
I see what you did there
Re:Backbone.js views done right
by jcromartie on Thursday June 14, 2012 @01:04PM
(#4112336)
See: "rocket surgeon", or "enough rope to shoot yourself in the foot".
Also: jashkenas wrote Backbone.
Seriously?! My fellow nerds drive me insane sometimes with their ridiculous focus on details that mean absolutely nothing. Arrrrrgh.
Re:Backbone.js views done right
by mark_story on Thursday June 14, 2012 @09:05PM
(#4114431)
I always assume people nitpicking pointless details have nothing better to say, but still want to say something. Plus, look how smart he/she looked.
Why would you want to have a view that dumps out its HTML as a string? If a string of HTML is all you want, don't use a view, just use a template.
But putting that aside for a second ... for this particular example, how about this:
... or if you were in earnest about only needing the raw HTML from the sub-view, how about just rendering the row templates within the table template, making your render function as simple as this: