Reputation: 2835
I don't get it. When using JSFiddle, this simple example works fine:
SearchView = Backbone.View.extend({
initialize: function(){
alert('hello');
}
});
var search_view = new SearchView;
However when I implement the same thing into a Node application I get the following error on load of the page.
"Uncaught TypeError: undefined is not a function" - localhost:3000/bower_components/backbone/backbone.js:1105
I have no doubt I'm missing something really simple, but it's driving me nuts.
In both cases I'm linking to JQuery, Underscore and Backbone .. yet someone my project does not work. I check my project in here ... https://[email protected]/warrickf/searchview.git
Thanks Warrick
Upvotes: 1
Views: 92
Reputation: 25892
I think there is some problem with your backbone.js version. I just went to your fiddle copied the location of backbone.js library and added to index.jade.
add this line before your script tag in index.jade
script(type="text/javascript" src="http://ajax.cdnjs.com/ajax/libs/backbone.js/0.3.3/backbone-min.js")
If you will see your fiddle it's using some 0.3.3 version of backbone.js. If I add version 1.1.2 in your fiddle it won't work. So you have to figure out what version you have to use.
Upvotes: 0
Reputation: 36
The problem is that you are loading jQuery after Backbone. Backbone is dependent on both jQuery and Underscore, so you will need to load them both before loading Backbone.
script(src='/bower_components/underscore/underscore.js')
script(src='/bower_components/jquery/dist/jquery.js')
script(src='/bower_components/backbone/backbone.js')
Upvotes: 2