[Pkg-javascript-commits] [backbone] 107/281: merging in #758 -- although the API leaves something to be desired.
Jonas Smedegaard
js at moszumanska.debian.org
Sat May 3 17:02:01 UTC 2014
This is an automated email from the git hooks/post-receive script.
js pushed a commit to tag 0.9.0
in repository backbone.
commit 9fc7443d34683f0a758d7bea0c30f310c0936578
Author: Jeremy Ashkenas <jashkenas at gmail.com>
Date: Wed Nov 23 17:32:04 2011 -0500
merging in #758 -- although the API leaves something to be desired.
---
backbone.js | 18 +++++-------------
test/view.js | 2 +-
2 files changed, 6 insertions(+), 14 deletions(-)
diff --git a/backbone.js b/backbone.js
index 3085211..782e030 100644
--- a/backbone.js
+++ b/backbone.js
@@ -873,17 +873,6 @@
this.initialize.apply(this, arguments);
};
- // Element lookup, scoped to DOM elements within the current view.
- // This should be prefered to global lookups, if you're dealing with
- // a specific view.
- var selectorDelegate = function(selector) {
- if (typeof selector == 'undefined') {
- return $(this.el);
- } else {
- return $(selector, this.el);
- };
- };
-
// Cached regex to split keys for `delegate`.
var eventSplitter = /^(\S+)\s*(.*)$/;
@@ -896,8 +885,11 @@
// The default `tagName` of a View's element is `"div"`.
tagName : 'div',
- // Attach the `selectorDelegate` function as the `$` property.
- $ : selectorDelegate,
+ // jQuery delegate for element lookup, scoped to DOM elements within the
+ // current view. This should be prefered to global lookups where possible.
+ $ : function(selector) {
+ return (selector == null) ? $(this.el) : $(selector, this.el);
+ },
// Initialize is an empty function by default. Override it with your own
// initialization logic.
diff --git a/test/view.js b/test/view.js
index cdf98e5..152f1d4 100644
--- a/test/view.js
+++ b/test/view.js
@@ -41,7 +41,7 @@ $(document).ready(function() {
var counter = counter2 = 0;
view.el = document.body;
view.increment = function(){ counter++; };
- $(view.el).bind('click', function(){ counter2++; });
+ view.$().bind('click', function(){ counter2++; });
var events = {"click #qunit-banner": "increment"};
view.delegateEvents(events);
$('#qunit-banner').trigger('click');
--
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