by jashkenas · 14y ago · 0 comments
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:
render: ->
this.$el.html JST["table_view_template"]()
tbody = this.$el('tbody')
for person in this.collection.models
view = new TableRowView model: person
tbody.append view.render().el
... 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: render: ->
this.$el.html this.template people: this.collectionAnd 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.
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.
Also: jashkenas wrote Backbone.