According to backbone js website:
Backbone's only hard dependency is Underscore.js ( > 1.3.1). For RESTful persistence, history support via Backbone.Router and DOM manipulation with Backbone.View, include json2.js, and either jQuery (1.4.2) or Zepto.
I tested with code below, removing jQuery and the Backbone view throws an error.
<html>
<head>
<title>asda</title>
<!--<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>-->
<script src="http://documentcloud.github.com/underscore/underscore.js"></script>
<script src="http://documentcloud.github.com/backbone/backbone.js"></script>
<script type="text/javascript" charset="utf-8" async defer>
SearchView = Backbone.View.extend({
initialize: function(){
alert("Alerts suck.");
}
});
// The initialize function is always called when instantiating a Backbone View.
// Consider it the constructor of the class.
var search_view = new SearchView;
</script>
</head>
<body>
</body>
</html>
How can Backbone.View and Backbone.Router work without jQuery?
Try to use jBone, this is library for DOM manipulations in modern browsers, jBone developed special for Backbone, only 2kb gzipped and jQuery like API.
You can use the
Backbone.Model
without jQuery, butBackbone.View
will require either jQuery or Zepto, just like the docs state.Backbone is now even easier to decouple from jQuery.
Check this out:
https://github.com/jashkenas/backbone/wiki/Using-Backbone-without-jQuery
While Backbone.View does depend on a DOM manipulation library, ie you can't use vanilla javascript that is not organized in to a library of some sort, you can configure Backbone to use whatever library you'd like.
See the following from the Backbone source:
Calling this method will allow you to use whatever library you want.
For example: