Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixes #232

  • Loading branch information...
commit 67d39c926f05e3767658f700ed204a58c7396cef 1 parent f09a33f
@addyosmani authored raDiesle committed
Showing with 7 additions and 9 deletions.
  1. +5 −6 index.html
  2. +2 −3 index.md
View
11 index.html
@@ -5435,25 +5435,24 @@ <h3 id="boilerplate-rendering-code"><a href="#TOC">Boilerplate Rendering Code</a
&lt;div class=&quot;row&quot;&gt;
&lt;label&gt;First Name:&lt;/label&gt;
&lt;span&gt;&lt;%= firstName %&gt;&lt;/span&gt;
- &lt;div&gt;
+ &lt;/div&gt;
&lt;div class=&quot;row&quot;&gt;
&lt;label&gt;Last Name:&lt;/label&gt;
&lt;span&gt;&lt;%= lastName %&gt;&lt;/span&gt;
- &lt;div&gt;
+ &lt;/div&gt;
&lt;div class=&quot;row&quot;&gt;
&lt;label&gt;Email:&lt;/label&gt;
&lt;span&gt;&lt;%= email %&gt;&lt;/span&gt;
- &lt;div&gt;
+ &lt;/div&gt;
&lt;/script&gt;
&lt;/pre&gt;</code></pre>
<pre class="sourceCode javascript"><code class="sourceCode javascript"><span class="kw">var</span> MyView = <span class="kw">Backbone.View</span>.<span class="fu">extend</span>({
- <span class="dt">template</span>: <span class="ch">&#39;#my-view-template&#39;</span>,
+ <span class="dt">template</span>: $(<span class="ch">&#39;#my-view-template&#39;</span>).<span class="fu">html</span>(),
<span class="dt">render</span>: <span class="kw">function</span>(){
<span class="co">// compile the Underscore.js template</span>
- <span class="kw">var</span> template = $(<span class="ch">&#39;#my-view-template&#39;</span>);
- <span class="kw">var</span> compiledTemplate = <span class="kw">_</span>.<span class="fu">template</span>(template);
+ <span class="kw">var</span> compiledTemplate = <span class="kw">_</span>.<span class="fu">template</span>(<span class="kw">this</span>.<span class="fu">template</span>);
<span class="co">// render the template with the model data</span>
<span class="kw">var</span> data = <span class="kw">this</span>.<span class="fu">model</span>.<span class="fu">toJSON</span>();
View
5 index.md
@@ -6827,13 +6827,12 @@ Consider the code that it typically requires to render a view with Backbone and
```javascript
var MyView = Backbone.View.extend({
- template: '#my-view-template',
+ template: $('#my-view-template').html(),
render: function(){
// compile the Underscore.js template
- var template = $('#my-view-template');
- var compiledTemplate = _.template(template);
+ var compiledTemplate = _.template(this.template);
// render the template with the model data
var data = this.model.toJSON();
Please sign in to comment.
Something went wrong with that request. Please try again.