[Pkg-javascript-commits] [backbone] 17/19: adding a brief aside about super.

Jonas Smedegaard js at moszumanska.debian.org
Sat May 3 16:58:38 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to tag 0.1.1
in repository backbone.

commit c211499619f456b5f80136d718490e43fd95cb0c
Author: Jeremy Ashkenas <jashkenas at gmail.com>
Date:   Wed Oct 13 22:33:26 2010 -0400

    adding a brief aside about super.
---
 index.html | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/index.html b/index.html
index 2c57ec4..9fd9061 100644
--- a/index.html
+++ b/index.html
@@ -310,9 +310,7 @@
       gzipped, and megabytes of JavaScript, CSS, and images when loaded in the browser
       — there's a lot of room underneath for libraries of a more moderate scope.
       Backbone is a <i>2 kilobyte</i> include that provides
-      just the core concepts of models, events (key-value binding), collections,
-      views, and persistence. A much closer relative to Backbone is
-      <a href="http://benpickles.github.com/js-model/">js-model</a>.
+      just the core concepts of models, events, collections, views, and persistence.
     </p>
 
     <p>
@@ -451,6 +449,25 @@ var Note = Backbone.Model.extend({
 });
 </pre>
 
+    <p>
+      <i>
+        Brief aside on </i><tt>super</tt>: <i>JavaScript does not provide
+        a simple way to call super — the function of the same name defined
+        higher on the prototype chain. If you override a core function like
+        </i><tt>set</tt>,<i> or </i><tt>save</tt>, <i>and you want to invoke the
+        parent object's implementation, you'll have to explicitly call it, along these lines:
+      </i>
+    </p>
+    
+<pre>
+var Note = Backbone.Model.extend({
+  set: function(attributes, options) {
+    Backbone.Model.prototype.set.call(this, attributes, options);
+    ...
+  },
+});
+</pre>
+
     <p id="Model-constructor">
       <b class="header">constructor / initialize</b><code>new Model([attributes])</code>
       <br />

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/backbone.git



More information about the Pkg-javascript-commits mailing list