diff --git a/backbone.js b/backbone.js index bab8a7fd..383ecdd7 100644 --- a/backbone.js +++ b/backbone.js @@ -38,16 +38,7 @@ if (!_ && (typeof require !== 'undefined')) _ = require('underscore'); // For Backbone's purposes, jQuery, Zepto, or Ender owns the `$` variable. - var $ = root.jQuery || root.Zepto || root.ender; - - // Set the JavaScript library that will be used for DOM manipulation and - // Ajax calls (a.k.a. the `$` variable). By default Backbone will use: jQuery, - // Zepto, or Ender; but the `setDomLibrary()` method lets you inject an - // alternate JavaScript library (or a mock library for testing your views - // outside of a browser). - Backbone.setDomLibrary = function(lib) { - $ = lib; - }; + Backbone.$ = root.jQuery || root.Zepto || root.ender; // Runs Backbone.js in *noConflict* mode, returning the `Backbone` variable // to its previous owner. Returns a reference to this Backbone object. @@ -1017,16 +1008,16 @@ var oldIE = (isExplorer.exec(navigator.userAgent.toLowerCase()) && (!docMode || docMode <= 7)); if (oldIE && this._wantsHashChange) { - this.iframe = $('').hide().appendTo('body')[0].contentWindow; + this.iframe = Backbone.$('').hide().appendTo('body')[0].contentWindow; this.navigate(fragment); } // Depending on whether we're using pushState or hashes, and whether // 'onhashchange' is supported, determine how we check the URL state. if (this._hasPushState) { - $(window).bind('popstate', this.checkUrl); + Backbone.$(window).bind('popstate', this.checkUrl); } else if (this._wantsHashChange && ('onhashchange' in window) && !oldIE) { - $(window).bind('hashchange', this.checkUrl); + Backbone.$(window).bind('hashchange', this.checkUrl); } else if (this._wantsHashChange) { this._checkUrlInterval = setInterval(this.checkUrl, this.interval); } @@ -1060,7 +1051,7 @@ // Disable Backbone.history, perhaps temporarily. Not useful in a real app, // but possibly useful for unit testing Routers. stop: function() { - $(window).unbind('popstate', this.checkUrl).unbind('hashchange', this.checkUrl); + Backbone.$(window).unbind('popstate', this.checkUrl).unbind('hashchange', this.checkUrl); clearInterval(this._checkUrlInterval); History.started = false; }, @@ -1201,8 +1192,8 @@ // make: function(tagName, attributes, content) { var el = document.createElement(tagName); - if (attributes) $(el).attr(attributes); - if (content != null) $(el).html(content); + if (attributes) Backbone.$(el).attr(attributes); + if (content != null) Backbone.$(el).html(content); return el; }, @@ -1210,7 +1201,7 @@ // re-delegation. setElement: function(element, delegate) { if (this.$el) this.undelegateEvents(); - this.$el = (element instanceof $) ? element : $(element); + this.$el = element instanceof Backbone.$ ? element : Backbone.$(element); this.el = this.$el[0]; if (delegate !== false) this.delegateEvents(); return this; @@ -1371,7 +1362,7 @@ // Set the default implementation of `Backbone.ajax` to proxy through to `$`. Backbone.ajax = function() { - return $.ajax.apply($, arguments); + return Backbone.$.ajax.apply(Backbone.$, arguments); }; // Wrap an optional error callback with a fallback error event. diff --git a/index.html b/index.html index dcbcbb83..7de087fe 100644 --- a/index.html +++ b/index.html @@ -343,7 +343,6 @@
fetchcollection.fetch([options])
@@ -2391,14 +2390,6 @@ var localBackbone = Backbone.noConflict();
var model = localBackbone.Model.extend(...);
-
- setDomLibraryBackbone.setDomLibrary(jQueryNew);
-
- If you have multiple copies of jQuery on the page, or simply want
- to tell Backbone to use a particular object as its DOM / Ajax library,
- this is the function for you.
-
@@ -2447,15 +2438,15 @@ var model = localBackbone.Model.extend(...);
- New Rdio was developed from the ground - up with a component based framework based on Backbone.js. Every component - on the screen is dynamically loaded and rendered, with data provided by the - Rdio API. When changes are pushed, - every component can update itself without reloading the page or interrupting - the user's music. All of this relies on Backbone's views and models, - and all URL routing is handled by Backbone's Router. When data changes are - signaled in realtime, Backbone's Events notify the interested components - in the data changes. Backbone forms the core of the new, dynamic, realtime + New Rdio was developed from the ground + up with a component based framework based on Backbone.js. Every component + on the screen is dynamically loaded and rendered, with data provided by the + Rdio API. When changes are pushed, + every component can update itself without reloading the page or interrupting + the user's music. All of this relies on Backbone's views and models, + and all URL routing is handled by Backbone's Router. When data changes are + signaled in realtime, Backbone's Events notify the interested components + in the data changes. Backbone forms the core of the new, dynamic, realtime Rdio web and desktop applications.
@@ -2475,7 +2466,7 @@ var model = localBackbone.Model.extend(...); The app also uses Zepto, Underscore.js, SASS, iScroll, - HTML5 LocalStorage and Canvas. The tech team blogged about + HTML5 LocalStorage and Canvas. The tech team blogged about their experiences using LocalStorage to improve mobile performance. @@ -2593,15 +2584,15 @@ var model = localBackbone.Model.extend(...);
-
+
- Pitchfork uses Backbone.js to power - its site-wide audio player, Pitchfork.tv, - location routing, a write-thru page fragment cache, and more. Backbone.js - (and Underscore.js) helps the team - create clean and modular components, + Pitchfork uses Backbone.js to power + its site-wide audio player, Pitchfork.tv, + location routing, a write-thru page fragment cache, and more. Backbone.js + (and Underscore.js) helps the team + create clean and modular components, move very quickly, and focus on the site, not the spaghetti.
@@ -2610,7 +2601,7 @@ var model = localBackbone.Model.extend(...);
-
+
@@ -2874,15 +2865,15 @@ var model = localBackbone.Model.extend(...);
-
+
- KANO/APPS used Backbone.js to create - KANO/GAMES, a social gaming website. - KANO/GAMES relies on Backbone.js for almost every aspect of the site: - for seamless page loading, to construct menus, game listings and game - canvases, to build interactive HTML5 avatars, and for + KANO/APPS used Backbone.js to create + KANO/GAMES, a social gaming website. + KANO/GAMES relies on Backbone.js for almost every aspect of the site: + for seamless page loading, to construct menus, game listings and game + canvases, to build interactive HTML5 avatars, and for user and developer profiles, and live feeds.
@@ -2910,14 +2901,14 @@ var model = localBackbone.Model.extend(...);
-
+
- scroll kit is a new kind of website - builder that makes designing a web page feel more like drawing. - The workspace is a single-page web application built with Rails and Backbone.js. - In scroll kit, every DOM element is associated with a Backbone model, so that + scroll kit is a new kind of website + builder that makes designing a web page feel more like drawing. + The workspace is a single-page web application built with Rails and Backbone.js. + In scroll kit, every DOM element is associated with a Backbone model, so that style changes that are made to an element automatically update the model and propagate the change across all its views. Try it out. diff --git a/test/setdomlibrary.js b/test/setdomlibrary.js deleted file mode 100644 index b9efe504..00000000 --- a/test/setdomlibrary.js +++ /dev/null @@ -1,31 +0,0 @@ -$(document).ready(function(jQuery) { - - // a mock object that looks sufficiently jQuery-ish - var myLib = function() { - return { - attr: function() { return "spam" }, - html: function() { return "spam" }, - hasClass: function() { return "spam" } - }; - }; - - var viewAttrs = { id: 'test-setdomlibrary', className: 'test-setdomlibrary' } - - module("Backbone.setDomLibrary", { - - teardown: function() { - Backbone.setDomLibrary(jQuery); - } - - }); - - test('Changing jQuery library to custom library', function() { - Backbone.setDomLibrary(myLib); - var view = new Backbone.View(viewAttrs); - ok(view.$el.hasClass('test-setdomlibrary') === 'spam'); - Backbone.setDomLibrary(jQuery); - var view = new Backbone.View(viewAttrs); - ok(view.$el.hasClass('test-setdomlibrary')); - }); - -}); diff --git a/test/test.html b/test/test.html index f828a449..6f70c74b 100644 --- a/test/test.html +++ b/test/test.html @@ -19,7 +19,6 @@ -