无法在 Sencha 中点击按钮
Can't tap button in Sencha
我正在使用 Sencha Touch 开发移动应用程序。问题是我点击按钮后没有切换到新视图。
我的代码:
view/LoginUsername.js
Ext.define('RibMobile.view.LoginUsername', {
extend: 'Ext.form.Panel',
xtype: 'loginusernamepage',
requires: ['Ext.form.FieldSet', 'Ext.form.Password', 'Ext.Label',
'Ext.Img'
],
config: {
title: 'Login',
items: [{
/* ? */
}, {
xtype: 'button',
itemId: 'nextButton',
ui: 'action',
padding: '10px',
text: 'Next'
}, {
/* ? */
}]
}
});
controller/Login.js
Ext.define('RibMobile.controller.Login', {
extend: 'Ext.app.Controller',
config: {
refs: {},
control: {
nextButton: {
// On the tap event, call onNewTap
tap: 'onPasswordTap'
}
}
},
//called when the Application is launched, remove if not needed
launch: function(app) {},
onPasswordTap: function() {
// When the user taps on the button, create a new reference of our New view, and set it as the active
// item of Ext.Viewport
Ext.Viewport.setActiveItem(Ext.create('RibMobile.view.LoginPassword'));
}
});
app.js
Ext.application({
name: 'RibMobile',
requires: [
'Ext.MessageBox'
],
controllers: [ 'Main', 'Login' ],
views: [
'Contact',
'Locate',
'LoginUsername',
'LoginPassword',
'Main',
'Promotion'
],
/* ? */
如何触发按钮?
您错过了按钮与其控件之间的映射。
添加对它的引用,它应该可以工作:
refs: {
nextButton: 'button[itemId=nextButton]'
}
我正在使用 Sencha Touch 开发移动应用程序。问题是我点击按钮后没有切换到新视图。
我的代码:
view/LoginUsername.js
Ext.define('RibMobile.view.LoginUsername', {
extend: 'Ext.form.Panel',
xtype: 'loginusernamepage',
requires: ['Ext.form.FieldSet', 'Ext.form.Password', 'Ext.Label',
'Ext.Img'
],
config: {
title: 'Login',
items: [{
/* ? */
}, {
xtype: 'button',
itemId: 'nextButton',
ui: 'action',
padding: '10px',
text: 'Next'
}, {
/* ? */
}]
}
});
controller/Login.js
Ext.define('RibMobile.controller.Login', {
extend: 'Ext.app.Controller',
config: {
refs: {},
control: {
nextButton: {
// On the tap event, call onNewTap
tap: 'onPasswordTap'
}
}
},
//called when the Application is launched, remove if not needed
launch: function(app) {},
onPasswordTap: function() {
// When the user taps on the button, create a new reference of our New view, and set it as the active
// item of Ext.Viewport
Ext.Viewport.setActiveItem(Ext.create('RibMobile.view.LoginPassword'));
}
});
app.js
Ext.application({
name: 'RibMobile',
requires: [
'Ext.MessageBox'
],
controllers: [ 'Main', 'Login' ],
views: [
'Contact',
'Locate',
'LoginUsername',
'LoginPassword',
'Main',
'Promotion'
],
/* ? */
如何触发按钮?
您错过了按钮与其控件之间的映射。
添加对它的引用,它应该可以工作:
refs: {
nextButton: 'button[itemId=nextButton]'
}