Mirat Can Bayrak
Mirat Can Bayrak

Reputation: 651

How to access models inside Backbone Marionete App?

actually i'm a backend developer so be gentle if my question is so dumb :)

I have an Backbone app initialized like this:

var AgendaApp = Mn.Application.extend({
    onStart: function() {
        ...
        ...

        var bookings = new Bookings();
        bookings.startStream({
            remove: false
        });
    }
    var agendaApp = ...

As you see bookings istance is staying inside onStart function scope. There is no chance to access them using debug console. For example i want to run something like this:

agendaApp.bookings.fetch()

What frontend developers doing at these stiuations?

Upvotes: 0

Views: 26

Answers (1)

Kevin Christopher Henry
Kevin Christopher Henry

Reputation: 48932

Make the model a property of the app, e.g. this.bookings = new Bookings(). Then you can access it anywhere you have the app, e.g. agendaApp.bookings.fetch().

Upvotes: 1

Related Questions