<story><title>Backbone.js views done right</title><url>http://blog.gaslightsoftware.com/post/24538291598/backbone-js-views-done-the-right-way?utm_medium=hackernews</url><text></text></story><parent_chain></parent_chain><comment><author>jashkenas</author><text>Whoa there nellie. Complexity ahoy.&lt;p&gt;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&apos;t use a view, just use a template.&lt;p&gt;But putting that aside for a second ... for this particular example, how about this:&lt;p&gt;&lt;pre&gt;&lt;code&gt;    render: -&amp;#62;
      this.$el.html JST[&quot;table_view_template&quot;]()
      tbody = this.$el(&apos;tbody&apos;)
      for person in this.collection.models
        view = new TableRowView model: person
        tbody.append view.render().el
&lt;/code&gt;&lt;/pre&gt;
... 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:&lt;p&gt;&lt;pre&gt;&lt;code&gt;    render: -&amp;#62;
      this.$el.html this.template people: this.collection&lt;/code&gt;&lt;/pre&gt;</text></comment>
<story><title>Backbone.js views done right</title><url>http://blog.gaslightsoftware.com/post/24538291598/backbone-js-views-done-the-right-way?utm_medium=hackernews</url><text></text></story><parent_chain></parent_chain><comment><author>jcromartie</author><text>This is getting way too many votes for what amounts to bad advice. I think you should keep subview rendering methods out of your templates (i.e. keep your templates &quot;dumb&quot;). You can just create placeholder elements in the template, and then pass the placeholder element to the subview constructor. Or you can just append a list of collection-based subviews to a single container element.&lt;p&gt;You should be able to write Backbone apps without resorting to stuff like $(&quot;#row_#{@model.id}&quot;)&lt;p&gt;And for an example, here&apos;s a gist &lt;a href=&quot;https://gist.github.com/2931491&quot; rel=&quot;nofollow&quot;&gt;https://gist.github.com/2931491&lt;/a&gt;</text></comment>