Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

For #342 - updates model paragraph

  • Loading branch information...
commit 7e69a99f1f462fa0b371bec7c978400dc7568a72 1 parent 4dcc717
Addy Osmani authored
BIN  backbone-fundamentals.epub
View
Binary file not shown
2  backbone-fundamentals.md
View
@@ -687,7 +687,7 @@ console.log(todo2.toJSON());
**Model.set()**
-`Model.set()` allows us to pass attributes into an instance of our model. Backbone uses Model.set() to know when to broadcast to its listeners that the model's data has changed.
+`Model.set()` sets a hash containing one or more attributes on the model. When any of these attributes alter the state of the model, a "change" event is triggered on it. Change events for each attribute are also triggered and can be bound to (e.g `change:name`, `change:age`).
```javascript
var Todo = Backbone.Model.extend({
2  backbone-fundamentals.rtf
View
@@ -531,7 +531,7 @@ var todo2 = new Todo(\{\line
// logs: \{"title":"Try these examples and check results in console.","completed":true\}\line
console.log(todo2.toJSON());\par}
{\pard \ql \f0 \sa180 \li0 \fi0 {\b Model.set()}\par}
-{\pard \ql \f0 \sa180 \li0 \fi0 {\f1 Model.set()} allows us to pass attributes into an instance of our model. Backbone uses Model.set() to know when to broadcast to its listeners that the model\u8217's data has changed.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 {\f1 Model.set()} sets a hash containing one or more attributes on the model. When any of these attributes alter the state of the model, a \u8220"change\u8221" event is triggered on it. Change events for each attribute are also triggered and can be bound to (e.g {\f1 change:name}, {\f1 change:age}).\par}
{\pard \ql \f0 \sa180 \li0 \fi0 \f1 var Todo = Backbone.Model.extend(\{\line
// Default todo attribute values\line
defaults: \{\line
2  chapters/03-internals.md
View
@@ -170,7 +170,7 @@ console.log(todo2.toJSON());
**Model.set()**
-`Model.set()` allows us to pass attributes into an instance of our model. Backbone uses Model.set() to know when to broadcast to its listeners that the model's data has changed.
+`Model.set()` sets a hash containing one or more attributes on the model. When any of these attributes alter the state of the model, a "change" event is triggered on it. Change events for each attribute are also triggered and can be bound to (e.g `change:name`, `change:age`).
```javascript
var Todo = Backbone.Model.extend({
2  index.html
View
@@ -864,7 +864,7 @@ <h4 id="getters-setters"><a href="#TOC">Getters &amp; Setters</a></h4>
<span class="co">// logs: {&quot;title&quot;:&quot;Try these examples and check results in console.&quot;,&quot;completed&quot;:true}</span>
<span class="kw">console</span>.<span class="fu">log</span>(<span class="kw">todo2</span>.<span class="fu">toJSON</span>());</code></pre>
<p><strong>Model.set()</strong></p>
-<p><code>Model.set()</code> allows us to pass attributes into an instance of our model. Backbone uses Model.set() to know when to broadcast to its listeners that the model’s data has changed.</p>
+<p><code>Model.set()</code> sets a hash containing one or more attributes on the model. When any of these attributes alter the state of the model, a <q>change</q> event is triggered on it. Change events for each attribute are also triggered and can be bound to (e.g <code>change:name</code>, <code>change:age</code>).</p>
<pre class="sourceCode javascript"><code class="sourceCode javascript"><span class="kw">var</span> Todo = <span class="kw">Backbone.Model</span>.<span class="fu">extend</span>({
<span class="co">// Default todo attribute values</span>
<span class="dt">defaults</span>: {
Please sign in to comment.
Something went wrong with that request. Please try again.