Mur*_*san 1 extjs sencha-touch sencha-touch-2
我正在构建一个Sencha Touch应用程序,并在登录后挣扎着重定向或更改另一个视图.登录后我需要把它带到主页.但我在Login Controller的authenticateUser()下面的代码不起作用.
尝试使用Ext.Viewport.push(homePanel),Ext.Viewport.setActiveItem(homePanel).但没有任何作用.
LoginView
Ext.define("Mobile.view.LoginView", {
extend: "Ext.form.FormPanel",
alias: "widget.mylogin",
id: 'loginFormPanel',
config: {
name: 'loginform',
frame: true,
url: 'login/Authenticate',
title: 'Login',
items: [
{
xtype: 'fieldset',
itemId: 'LoginFieldset',
margin: '10 auto 0 auto ',
title: '',
items: [
{
//User Name field def
},
{
//Pwd Field Def
}
]
},
{
xtype: 'button',
id: 'loginButton',
text: 'Login',
action: 'login'
}
]
}
});
Run Code Online (Sandbox Code Playgroud)
登录控制器
Ext.define("Mobile.controller.LoginController", {
extend: "Ext.app.Controller",
views: ['LoginView', 'HomeView'],
models: ['UserModel'],
config: {
refs: {
loginForm: "#loginFormPanel"
},
control: {
'button[action=login]': {
tap: "authenticateUser"
}
}
},
authenticateUser: function (button) {
loginForm.submit({
method: 'POST',
success: function (form, result) {
//THIS IS NOT WORKING
Ext.Viewport.add(Ext.create('Mobile.view.HomeView'));
},
failure: function (form, result) {
console.log('Error');
Ext.Msg.alert('Check the logic for login and redirect');
}
});
}
});
Run Code Online (Sandbox Code Playgroud)
家庭观点
Ext.define('Mobile.view.HomeView', {
extend: 'Ext.Container',
id: 'homescreen',
alias: "widget.homepanel",
config: {
layout: {
type: 'card',
animation: {
type: 'flip'
}
},
items: [
{
xtype: 'toolbar',
docked: 'bottom',
id: 'Toolbar',
title: 'My App',
items: [
{
id: 'settingsBtn',
xtype: 'button',
iconCls: 'settings',
ui: 'plain',
iconMask: true
}
]
},
{
xclass: 'Mobile.view.ActionListView'
}
]
},
});
Run Code Online (Sandbox Code Playgroud)
App.JS
Ext.application({
name: "Mobile",
controllers: ["LoginController", "HomeController"],
views: ['LoginView', 'HomeView', 'ActionListView'],
models: ['UserModel', 'OrganizationModel', 'ActionModel'],
stores: ['OrganizationStore', 'ActionStore'],
launch: function () {
var loginPanel = Ext.create('Ext.Panel', {
layout: 'fit',
items: [
{
xtype: 'mylogin'
}
]
});
Ext.Viewport.add(loginPanel);
}
});
Run Code Online (Sandbox Code Playgroud)
任何人都有任何想法?已经参考使用sencha touch 2.0登录后加载另一个视图.但没有答案.请帮忙
您需要为HomeView创建一个参考:
refs: {
HomeView: {
autoCreate: true,
selector: 'HomeView',
xtype: 'HomeView'
},
}
Run Code Online (Sandbox Code Playgroud)
并将此视图设置为活动:
Ext.Viewport.setActiveItem(this.getHomeView());
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14343 次 |
| 最近记录: |