Backbone.$ is not a function
Closed this issue · 1 comments
Hey, i am new to the 'MVC'-World but i would like to get my Hands on it.
I liked Backbone because im not dependent on an node-driven system and lame-old jQuery. On top of that, the syntax is great.
Anyways - like i said - i don't like to use jQuery and stumbled upon this great addition to Backbone.
So i include Backbone and after that Backbone.NativeView with script-tags.
<script src="../underscore.js"></script>
<script src="../backbone.js"></script>
<script src="../backbone.nativeview.js"></script>
Then i've tried to add my first view and it caused the following error 'Backbone.$ is not a function'
These are the lines that i've tried getting to work:
Backbone.View = Backbone.NativeView;
var MainView = Backbone.View.extend();
var mainView = new MainView();
var MainView = Backbone.NativeView.extend();
var mainView = new MainView();
The call stack is as followed:
_.extend._ensureElement @ backbone.js:1105
Backbone.View @ backbone.js:1000
Backbone.NativeViewMixin.constructor @ backbone.nativeview.js:61
child @ backbone.js:1566
(anonymous function) @ script.js:83
It seems like he is trying to use the jQuery selector even though we defined our own $ Selector
$: function(selector) {
return this.el.querySelectorAll(selector);
},
Am i doing something wrong, have i missunderstood something? In both cases, can someone please give me an advice.
Thanks a lot.
Btw: I am using Backbone.NativeView.js 0.3.2 and Backbone.js 1.1.2 with Underscore.js 1.8.2 in the latest Chrome
Backbone hasn't yet released a version with the NativeView-compatible changes (they're new since Backbone 1.1.2).
In the meantime, use the master branch of Backbone or point your package manager to a more recent git SHA.
Sorry for the confusion, I know this has bitten quite a few folks. Let me add a note to the readme.