[Pkg-javascript-commits] [backbone] 71/101: first draft of docs is done.
Jonas Smedegaard
js at moszumanska.debian.org
Sat May 3 16:58:30 UTC 2014
This is an automated email from the git hooks/post-receive script.
js pushed a commit to tag 0.1.0
in repository backbone.
commit 727c299695d339ac94c2f9f76439a59eeb35dc21
Author: Jeremy Ashkenas <jashkenas at gmail.com>
Date: Tue Oct 12 15:58:40 2010 -0400
first draft of docs is done.
---
backbone.js | 3 +--
docs/backbone.html | 2 +-
index.html | 44 +++++++++++++++++++++++++++++++++++++++-----
test/vendor/qunit.js | 4 ++--
4 files changed, 43 insertions(+), 10 deletions(-)
diff --git a/backbone.js b/backbone.js
index 098c5fd..0c8c7b1 100644
--- a/backbone.js
+++ b/backbone.js
@@ -488,7 +488,6 @@
// Creating a Backbone.View creates its intial element outside of the DOM,
// if an existing element is not provided...
Backbone.View = function(options) {
- this.modes = {};
this._initialize(options || {});
if (this.options.el) {
this.el = this.options.el;
@@ -551,7 +550,7 @@
// Passing a selector of `el` binds to the view's root element.
// Change events are not delegated through the view because IE does not
// bubble change events at all.
- bindCallbacks : function(callbacks) {
+ handleEvents : function(callbacks) {
$(this.el).unbind();
if (!(callbacks || (callbacks = this.callbacks))) return this;
for (key in callbacks) {
diff --git a/docs/backbone.html b/docs/backbone.html
index 3457236..9c46169 100644
--- a/docs/backbone.html
+++ b/docs/backbone.html
@@ -364,7 +364,7 @@ and behavior.</p> </td> <td class="code">
Uses jQuery event delegation for efficiency.
Passing a selector of <code>el</code> binds to the view's root element.
Change events are not delegated through the view because IE does not
-bubble change events at all.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">bindCallbacks</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">callbacks</span><span class="p">)</span> <span class="p">{</span>
+bubble change events at all.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">handleEvents</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">callbacks</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">el</span><span class="p">).</span><span class="nx">unbind</span><span class="p">();</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="p">(</span><span class="nx">callbacks</span> <span class="o">||</span> <span class="p">(</span><span class="nx">callbacks</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">callbacks</span><span class="p">)))</span> <span class="k">return</span> <span class="k">this</span><span class="p">;</span>
<span class="k">for</span> <span class="p">(</span><span class="nx">key</span> <span class="k">in</span> <span class="nx">callbacks</span><span class="p">)</span> <span class="p">{</span>
diff --git a/index.html b/index.html
index d07d75a..31b6664 100644
--- a/index.html
+++ b/index.html
@@ -193,11 +193,11 @@
View
</a>
<ul class="toc_section">
- <li>– <a href="View-el">el</a></li>
- <li>– <a href="View-jQuery">$ (jQuery)</a></li>
- <li>– <a href="View-render">render</a></li>
- <li>– <a href="View-make">make</a></li>
- <li>– <a href="View-bindCallbacks">bindCallbacks</a></li>
+ <li>– <a href="#View-el">el</a></li>
+ <li>– <a href="#View-jQuery">$ (jQuery)</a></li>
+ <li>– <a href="#View-render">render</a></li>
+ <li>– <a href="#View-make">make</a></li>
+ <li>– <a href="#View-handleEvents">handleEvents</a></li>
</ul>
</div>
@@ -937,7 +937,41 @@ ui.Chapter = Backbone.View.extend({
initial <tt>view.el</tt>.
</p>
+ <p id="View-handleEvents">
+ <b class="header">handleEvents</b><code>handleEvents([events])</code>
+ <br />
+ Uses jQuery's <tt>delegate</tt> function to provide declarative callbacks
+ for DOM events within a view.
+ If an <b>events</b> hash is not passed directly, uses <tt>this.events</tt>
+ as the source. Events are written in the format <tt>{selector.event: callback}</tt>
+ </p>
+
+ <p>
+ For example, a view that displays a document in a search result might look
+ something like this:
+ </p>
+<pre>
+var DocumentView = Backbone.View.extend({
+
+ events: {
+ ".title.click" : "select",
+ ".title.dblclick" : "open",
+ ".icon.doc.contextmenu" : "showMenu",
+ ".show_notes.click" : "toggleNotes",
+ ".title .lock.click" : "editAccessLevel",
+ ".title .date.mouseover" : "showTooltip"
+ },
+
+ render: {
+ var data = this.document.attributes();
+ this.el.html(this.template.render(data));
+ this.handleEvents();
+ return this;
+ }
+
+});
+</pre>
diff --git a/test/vendor/qunit.js b/test/vendor/qunit.js
index 1fc2fe1..0c99937 100644
--- a/test/vendor/qunit.js
+++ b/test/vendor/qunit.js
@@ -695,7 +695,7 @@ QUnit.equiv = function () {
}
// Call the o related callback with the given arguments.
- function bindCallbacks(o, callbacks, args) {
+ function handleEvents(o, callbacks, args) {
var prop = hoozit(o);
if (prop) {
if (hoozit(callbacks[prop]) === "function") {
@@ -819,7 +819,7 @@ QUnit.equiv = function () {
} else if (a === null || b === null || typeof a === "undefined" || typeof b === "undefined" || hoozit(a) !== hoozit(b)) {
return false; // don't lose time with error prone cases
} else {
- return bindCallbacks(a, callbacks, [b, a]);
+ return handleEvents(a, callbacks, [b, a]);
}
// apply transition with (1..n) arguments
--
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