I am new to Backbone.js. For experimenting / initial development, I had everything on one page in the tag, but I started separating out the code into a separate .js file. After I did that I get an error coming from the Router.
Uncaught TypeError: Object [object Object] has no method 'apply'
Here is my Router code:
var AppRouter = new Backbone.Router.extend({
routes: {
":uuid": "details"
},
details: function (uuid) {
// load details
new DetailView({id: uuid, el: $('#detailView')});
}
});
var appRouter = new AppRouter;
I have the Models/Views loaded in a file tag above, but even if I comment out the file's tag or empty the file, it still displays thing error.
The line throwing the error is var appRouter = new AppRouter;
I'm I doing something wrong with the router code.
Thanks!! Andrew
I am new to Backbone.js. For experimenting / initial development, I had everything on one page in the tag, but I started separating out the code into a separate .js file. After I did that I get an error coming from the Router.
Uncaught TypeError: Object [object Object] has no method 'apply'
Here is my Router code:
var AppRouter = new Backbone.Router.extend({
routes: {
":uuid": "details"
},
details: function (uuid) {
// load details
new DetailView({id: uuid, el: $('#detailView')});
}
});
var appRouter = new AppRouter;
I have the Models/Views loaded in a file tag above, but even if I comment out the file's tag or empty the file, it still displays thing error.
The line throwing the error is var appRouter = new AppRouter;
I'm I doing something wrong with the router code.
Thanks!! Andrew
Share Improve this question asked Jun 14, 2013 at 14:20 Andrew MadonnaAndrew Madonna 1555 silver badges12 bronze badges 3 |1 Answer
Reset to default 25Remove the new
in var AppRouter = new Backbone.Router.extend({...
new
invar AppRouter = new Backbone.Router.extend({...
– Andbdrew Commented Jun 14, 2013 at 14:21var AppRouter = new Backbone.Router.extend({
tovar AppRouter = Backbone.Router.extend({
and changevar appRouter = new AppRouter;
tovar appRouter = new AppRouter();
– Dmitry Manannikov Commented Jun 14, 2013 at 14:23