View Full Version : MVC, how to render view from controller?
netresource
1 Nov 2011, 12:43 AM
I have two controllers: Homes and Users
Homes controller with HomePage view and Users controller with LoginForm view
I want to call LoginForm view from a login button on HomePage view.
How can do it with ST 2.x MVC?
emielvangoor
1 Nov 2011, 1:27 AM
Add on button click event the login view to your desired panel (By xtype, see alias within a view)
See:
http://docs.sencha.com/touch/2-0/#!/api/Ext.app.Controller-method-control
netresource
1 Nov 2011, 1:43 AM
in 1.x i can do it with
on HomePage view
onLoginAction: function () {
Ext.dispatch({
controller: 'Users',
action: 'loginForm'
});
}
in User controller
loginForm: function () {
if ( ! App.views.loginForm){
App.views.loginForm = this.render({xtype: 'App.views.LoginForm',});}
var model = new App.models.User();
App.views.loginForm.load(model);
App.views.viewport.setActiveItem(App.views.loginForm, { type: 'slide', direction: 'left' });
}
but i can't do like this with 2.x
emielvangoor
1 Nov 2011, 1:54 AM
I don't have much experience with Touch (1 or 2) but Ext.dispatch doesn't exists anymore in Touch 2, maybe http://docs.sencha.com/touch/2-0/#!/api/Ext.app.Controller-method-getController will help you to get the controller...
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.