2014-03-02 1 views
0

here으로 묘사 된 바와 같이, 하위 모듈의 - startWithParent = false은 하위 Moudle을 응용 프로그램으로 시작하지 못하게합니다.마리온네 - "startWithParent = false"가 원인입니까?

sub-Moudue에서 startWithParent = false 이후 MyApp.start()은 서브 모듈 initializer을 실행하지 않아야합니다. 내가 추적하려고 할 때

는하지만 -

MyApp = new Marionette.Application(); 
MyApp.module("SubModule", function() { 
    // prevent starting with parent 
    this.startWithParent = false; 
    // Logs 
    console.log("Sub Module Created !"); 
}); 
MyApp.start(); 

Sub Module Created ! 로그, 서브 모듈 initializer가 조치를 취 것을 의미한다.

제게 설명해 주시겠습니까?

답변

5

코드는 내부

MyApp.module("SubModule", function() { 
    ... 
}); 

모듈 정의하고 즉시 호출합니다. 당신이 뭔가를 작성해야 모듈에 초기화를 추가하려면 :

MyApp = new Marionette.Application(); 
MyApp.module("SubModule", function() { 
    // prevent starting with parent 
    this.startWithParent = false; 

    this.addInitializer(function(){ 
     console.log("Sub Module Initialized !"); 
    }); 

    console.log("Sub Module Defined !"); 
}); 
MyApp.start(); 
console.log("My App Started !"); 
MyApp.SubModule.start(); 

그리고

는 콘솔에 당신은 볼 수 있습니다 :

Sub Module Defined ! 
My App Started ! 
Sub Module Initialized ! 
관련 문제