Skip to content
This repository
Browse code

Merge pull request #54 from g6scheme/1.5.2

1.5.2
  • Loading branch information...
commit 1d68645494687d9d6bdfe8f7347cebdeffeb5ab2 2 parents 70e9b33 + 2338528
Addy Osmani authored August 22, 2012

Showing 1 changed file with 9 additions and 7 deletions. Show diff stats Hide diff stats

  1. 16  book/index.html
16  book/index.html
@@ -4876,7 +4876,7 @@ <h2 id="detailmvp">MVP</h2>
4876 4876
 <p>At the end of the day, the underlying concerns we may have with MVC will likely hold true for MVP given that the differences between them are mainly semantic. As long as we are cleanly separating concerns into models, views and controllers (or presenters) we should be achieving most of the same benefits regardless of the variation we opt for.</p>
4877 4877
 
4878 4878
 <h3>MVC, MVP and Backbone.js</h3>
4879  
-<p>There are very few, if any architectural JavaScript frameworks that claim to implement the MVC or MVC patterns in their classical form as many JavaScript developers don't view MVC and MVP as being mutually exclusive (we are actually more likely to see MVP strictly implemented when looking at web frameworks such as ASP.net or GWT). This is because it's possible to have additional presenter/view logic in our application and yet still consider it a flavor of MVC.</p>
  4879
+<p>There are very few, if any architectural JavaScript frameworks that claim to implement the MVC or MVP patterns in their classical form as many JavaScript developers don't view MVC and MVP as being mutually exclusive (we are actually more likely to see MVP strictly implemented when looking at web frameworks such as ASP.net or GWT). This is because it's possible to have additional presenter/view logic in our application and yet still consider it a flavor of MVC.</p>
4880 4880
 <p>Backbone contributor <a href="http://ireneros.com/">Irene Ros</a> (of Boston-based Bocoup) subscribes to this way of thinking as when she separates views out into their own distinct components, she needs something to actually assemble them for her. This could either be a controller route (such as a <code>Backbone.Router</code>, covered later in the book) or a callback in response to data being fetched.</p>
4881 4881
 <p>That said, some developers do however feel that Backbone.js better fits the description of MVP than it does MVC. Their view is that:</p>
4882 4882
 <ul>
@@ -4971,15 +4971,17 @@ <h2 id="detailmvvm">MVVM</h2>
4971 4971
 <p>ViewModel:</p>
4972 4972
 <pre class="brush: js">
4973 4973
 var aViewModel = {
4974  
-    contactName: ko.observable( "John" );
  4974
+    contactName: ko.observable("John")
4975 4975
 };
  4976
+ko.applyBindings(aViewModel);
4976 4977
 </pre>
4977 4978
 <p>View:</p>
4978  
-<pre   class="brush: js">&lt;input id="source" data-bind="value: contactName, valueUpdate: "keyup" /&gt;&lt;/p&gt;
4979  
-
4980  
-&lt;div data-bind="visible: contactName().length &gt; 10"&gt;
4981  
-    You have a really long name!
4982  
-&lt;/div&gt;
  4979
+<pre class="brush: js">
  4980
+  &lt;p&gt;&lt;input id=&quot;source&quot; data-bind=&quot;value: contactName, valueUpdate: &#x27;keyup&#x27;&quot; /&gt;&lt;/p&gt;
  4981
+  &lt;div data-bind=&quot;visible: contactName().length &gt; 10&quot;&gt;
  4982
+      You have a really long name!
  4983
+  &lt;/div&gt;
  4984
+  &lt;p&gt;Contact name: &lt;strong data-bind=&quot;text: contactName&quot;&gt;&lt;/strong&gt;&lt;/p&gt;
4983 4985
 </pre>
4984 4986
 <p>Our input text-box (source) obtains it's initial value from <code>contactName</code>, automatically updating this value whenever contactName changes. As the data binding is two-way, typing into the text-box will update <code>contactName</code> accordingly so the values are always in sync.</p>
4985 4987
 <p>Although implementation specific to KnockoutJS, the <code>&lt;div&gt;</code> containing the "You have a really long name!" text also contains simple validation (once again in the form of data bindings). If the input exceeds 10 characters, it will display, otherwise it will remain hidden.</p>

0 notes on commit 1d68645

Please sign in to comment.
Something went wrong with that request. Please try again.