最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Backbone Marionette get region view - Stack Overflow

programmeradmin0浏览0评论

I have a marionette layout that has a region with a view inside. How can I get a reference to that view?

For example:

var layoutView = Backbone.Marionette.Layout.extend({
    regions: {
        myRegion: '.some-element'
    },
    initialize: function(){
        this.render();
        this.myView.show(new someView());
    },
    test: function(){
        var view = this.myRegion.get() // or something to retrieve the view?
    }
});

I mean, I can save the view instance into "this", but surely marionette must have a way of retrieving it...right?

I have a marionette layout that has a region with a view inside. How can I get a reference to that view?

For example:

var layoutView = Backbone.Marionette.Layout.extend({
    regions: {
        myRegion: '.some-element'
    },
    initialize: function(){
        this.render();
        this.myView.show(new someView());
    },
    test: function(){
        var view = this.myRegion.get() // or something to retrieve the view?
    }
});

I mean, I can save the view instance into "this", but surely marionette must have a way of retrieving it...right?

Share Improve this question asked Sep 12, 2013 at 20:38 VicVic 8,9717 gold badges47 silver badges56 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 20

It should just be this.myRegion.currentView and model if bound to view: myRegion.currentView.model

发布评论

评论列表(0)

  1. 暂无评论