A uses dominus instead of jQuery to allow Backbone to work with leaner dependencies.
bower install backbone.dominus
Will work with AMD, CommonJS, and also adds Backbone.DomView
to the root Backbone object.
By default Backbone will try to require('jquery')
and load the global jQuery object $
into Backbone.$
. For AMD you can set up require path configs to point jquery to dominus, and for CommonJS you can use aliasify to do the same.
A new view type is exposed called Backbone.DomView and can be extended. See Backbone.NativeView for other examples.
var view = Backbone.DomView.extend({
//...
});
git clone https://github.com/adamsea/backbone.dominus.git
npm install
bower install
npm test
Backbone.NativeView is a great reference example for building a jQuery-free Backbone. However, for ease of development within the Backbone ecosystem I was looking for lightweight jQuery replacements that could be useful on their own, while solving common problems.
Dominus is a good general-purpose DOM querying and manipulation library that will handle the following:
- Context-rooted queries in qSA - properly scoped lookup of view.$el sub-elements
- Event normalization - manages both attachEvent and addEventListener
- A jQuery-like fluent api for managing the DOM
Reqwest runs in jQuery-compat mode to work with Backbone Model and Collection instances, and gives you a solid api for making your own requests.