2014-03-06 103 views
0

我正在開發一個帶有區域的主應用程序的webapp。 首先,主要區域將以LoginModule開始,包含帶有html模板的LoginView。現在,在成功登錄之後,我希望LoginModule停止並隱藏視圖並啓動一系列新的模塊並進行渲染。 到目前爲止,我可以在應用程序區域渲染新的模塊,但是我無法停止和隱藏LoginView。我能做什麼 ?Backbone Marionette隱藏模塊

MyApp.module("LoginModule", function(LoginModule, MyApp, Backbone, Marionette, $,_){ 

LoginModule.startWithParent = true; 

//Private Data And Functions 
//E.g. var privateVar = "private"; 


//Public Data And Functions 
//E.g. LoginModule.publicVar = "public"; 

LoginModule.view = new LoginView(); 

//Initializer & Finalizer 
LoginModule.addInitializer(function(){ 

}); 

LoginModule.addFinalizer(function(){ 
    LoginModule.view = null; 
}); 

//Functions 
LoginModule.login = function(email, password){ 
    //Hardcoded Login 
    var marius = new User({name: "Marius", surname: "Widmann", password: "password", email: "[email protected]"}); 

    if(marius.get('email') === email){ 
        //Start the NavBarView in the header region 
        MyApp.header.show(new NavBarView()); 
/*####################*/   
    //Now here I want to stop the module or lets say hide the LoginView 

    /*####################*/ 
    }else{ 
     alert('Login failed'); 
    } 
} 

}); 

//Module Subscribers 
MyApp.module('LoginModule').on('LoginView:login', function(email, password){ 
this.login(email, password); 
}); 

回答

相關問題