[Pkg-javascript-commits] [backbone] 89/101: making events forgiving of non-selectors...
Jonas Smedegaard
js at moszumanska.debian.org
Sat May 3 16:58:32 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 ae693afe0851570fce1e151b078b8f9e78bc36c8
Author: Jeremy Ashkenas <jashkenas at gmail.com>
Date: Wed Oct 13 10:16:07 2010 -0400
making events forgiving of non-selectors...
---
backbone.js | 6 +++---
docs/backbone.html | 6 +++---
index.html | 6 ++++--
3 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/backbone.js b/backbone.js
index bb66d48..39afebf 100644
--- a/backbone.js
+++ b/backbone.js
@@ -515,7 +515,7 @@
};
// Cached regex to split keys for `handleEvents`.
- var eventSplitter = /^(\w+)\s+(.*)$/;
+ var eventSplitter = /^(\w+)\s*(.*)$/;
// Set up all inheritable **Backbone.View** properties and methods.
_.extend(Backbone.View.prototype, {
@@ -557,8 +557,8 @@
//
// pairs. Callbacks will be bound to the view, with `this` set properly.
// Uses jQuery event delegation for efficiency.
- // Passing a selector of `el` binds to the view's root element.
- // Change events are not delegated through the view because IE does not
+ // Omitting the selector binds the event to `this.el`.
+ // `"change"` events are not delegated through the view because IE does not
// bubble change events at all.
handleEvents : function(events) {
$(this.el).unbind();
diff --git a/docs/backbone.html b/docs/backbone.html
index e5bda3a..df89d0f 100644
--- a/docs/backbone.html
+++ b/docs/backbone.html
@@ -331,7 +331,7 @@ if an existing element is not provided...</p> </td> <td
This should be prefered to global jQuery lookups, if you're dealing with
a specific view.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="kd">var</span> <span class="nx">jQueryDelegate</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">selector</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="nx">$</span><span class="p">(</span><span class="nx">selector</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="p">};</span></pre></div> </td> </tr> <tr id="section-62"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-62">¶</a> </div> <p>Cached regex to split keys for <code>handleEvents</code>.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="kd">var</span> <span class="nx" [...]
+ <span class="p">};</span></pre></div> </td> </tr> <tr id="section-62"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-62">¶</a> </div> <p>Cached regex to split keys for <code>handleEvents</code>.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="kd">var</span> <span class="nx" [...]
<span class="nx">jQuery</span> <span class="o">:</span> <span class="nx">jQueryDelegate</span><span class="p">,</span></pre></div> </td> </tr> <tr id="section-66"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-66">¶</a> </div> <p><strong>render</strong> is the core function that your view should override, in order
to populate its element (<code>this.el</code>), with the appropriate HTML. The
convention is for <strong>render</strong> to always return <code>this</code>.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">render</span> <span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
@@ -357,8 +357,8 @@ needed, use <strong>make</strong> to manufacture elements, one at a time.</p>
<p>pairs. Callbacks will be bound to the view, with <code>this</code> set properly.
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
+Omitting the selector binds the event to <code>this.el</code>.
+<code>"change"</code> 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">handleEvents</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">events</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">events</span> <span class="o">||</span> <span class="p">(</span><span class="nx">events</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">events</span><span class="p">)))</span> <span class="k">return</span> <span class="k">this</span><span class="p">;</span>
diff --git a/index.html b/index.html
index 5e3dd17..d612484 100644
--- a/index.html
+++ b/index.html
@@ -1145,6 +1145,8 @@ $("#make-demo").append(el);
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>{"event selector": "callback"}</tt>.
+ Omitting the <tt>selector</tt> causes the event to be bound to the view's
+ root element (<tt>this.el</tt>).
</p>
<p>
@@ -1166,8 +1168,8 @@ $("#make-demo").append(el);
var DocumentView = Backbone.View.extend({
events: {
- "click .title" : "select",
- "dblclick .title" : "open",
+ "dblclick" : "open",
+ "click .icon.doc" : "select",
"contextmenu .icon.doc" : "showMenu",
"click .show_notes" : "toggleNotes",
"click .title .lock" : "editAccessLevel",
--
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