Frankie
Frankie

Reputation: 2265

Where do I put the code to bootstrap a collection into backbone.js?

I am new to javascript and I saw another post with a similar question but I'm not sure how to actually inject models into a backbone.js that lives in a separate file.

In my index file I have the following which is starting the app:

$(function () {
    var app = new App();        
    Backbone.history.start();
});  

Inside my application.js file I have the router which needs to have customers:

window.App = Backbone.Router.extend({     

    routes: {
        "": "home"
    },

    home: function () {
        console.log("route::home");
        console.log(this.customers);
    }
});

How can I actually get this.customers to be injected into the application? Where does this code live?

Upvotes: 1

Views: 127

Answers (0)

Related Questions