2014-02-19 1 views
1

나는 1 개 이상의 지역으로 된 마리오네트 어플리케이션을 보유하고 있습니다.백본. 마리오 네트 레이아웃 : 직접 region.layout.view에 액세스

App.addRegions({ 
    pageRegion: '#page', 
    contentsRegion :'#contents' 
}); 

App.pageRegion의 일부로 레이아웃을 추가합니다.

App.ConfiguratorLayout = Marionette.Layout.extend({ 
    template: '#configurator-page', 
    regions: { 
     CoreConfiguratorRegion: '#Core-Configurator-Region', 
     SomeOtherRegion:'#someOtherregion' 
    } 
}); 

이 레이아웃은 응용 프로그램이 시작되기 전에 렌더링됩니다.

App.addInitializer(function() { 
var configLayout = new App.ConfiguratorLayout(); 
App.pageRegion.show(configLayout); 
}); 

나중에 응용 프로그램에서 configLayout의 내용을 변경해야합니다.

나는 이런 식으로하려고합니다. App.pageRegion.ConfiguratorLayout.CoreConfiguratorRegion.show (someOtherLayout);

App.pageRegion의 $ el에서 DOM 선택기를 사용하는 방법 외에이 방법이있을 수 있습니다.

App.pageRegion. $ el.find ('#은 ...')

대신 앱 초기화에서의

답변

0

configLayout 초기화에 대한 참조를 유지 할 수있는 컨트롤러에 코드를 다음 show() 뭔가를 이동 그 지역 중 한 곳에서.

// pseudocode: 

ConfigController = Marionette.Controller.extend({ 

    showConfig: function() { 

     var layout = new App.ConfiguratorLayout(); 
     App.pageRegion.show(configLayout); 

     var someOtherLayout = new App.CoreConfiguratorLayout(); 
     layout.coreConfiguratorRegion.show(someOtherLayout); 

     // ... maybe create and show() some views here? 

    } 

}); 

App.addInitializer(function() { 
    var controller = new ConfigController(); 

    // more likely this would be bound to a router via appRoutes, instead of calling directly 
    controller.showConfig(); 
}); 
+1

레이아웃은 다양한 모듈간에 공유되어야했습니다. 하위 모듈 변수로 추가했습니다. 그것은 트릭을했다. 고마워요.하지만. – user3084985