0

Backbone newb here.

I have a view that extends Backbone.Marionette.Layout and has several regions. Some of these regions have several regions of their own and so on. If I am at the "top level" region, what is the best why to access methods of a child region/view?

I see that I can do something like this:

region1.currentView.region2.currentView.region3.method()

but that doesn't seem like a good idea. Any thoughts?

4

1 回答 1

2

你是对的。您将需要使用 Marionette Application 类中的事件聚合器来解耦您的应用程序。我使用以下方法在我的应用程序中进行通信。

app.vent.trigger('App:Core', { 'caller': 'LoginScreen' });

然后在我的应用程序的另一部分中,我正在监听这个事件。

App.vent.on('App:Core', function (data) {.....
于 2013-03-25T23:58:25.753 回答