Tôi đã có ứng dụng Sencha Touch 2 MVC với biểu mẫu dưới dạng chế độ xem. Tôi đang cố gắng để có được giá trị của nó từ bộ điều khiển mà không thành công.Sencha Touch 2 - Cách nhận các giá trị biểu mẫu?
Làm cách nào để thực hiện điều này? Tôi đang đăng mã xem/bộ điều khiển của mình cho mã này.
Xem:
Ext.define('MyApp.view.LoginForm', {
extend: 'Ext.form.Panel',
config: {
fullscreen: true,
items: [
{
xtype: 'fieldset',
title: 'Login',
id: 'loginform',
items: [
{
xtype: 'emailfield',
name: 'email',
label: 'Email'
},
{
xtype: 'passwordfield',
name: 'password',
label: 'Password'
}
]
},
{
xtype: 'button',
width: '50%',
text: 'Login',
ui: 'confirm',
id: 'btnSubmitLogin'
},
{
xtype: 'toolbar',
docked: 'top',
title: 'MyApp Mobile'
}
]
}
});
Và bộ điều khiển:
Ext.define("MyApp.controller.LoginForm", {
extend: "Ext.app.Controller",
config: {
refs: {
btnSubmitLogin: "#btnSubmitLogin"
},
control: {
btnSubmitLogin: {
tap: "onSubmitLogin"
}
}
},
onSubmitLogin: function() {
console.log("onSubmitLogin");
var values = app.views.LoginForm.loginform.getValues();
TryLogin(values['email'], values['password']);
},
launch: function() {
this.callParent();
console.log("LoginForm launch");
},
init: function() {
this.callParent();
console.log("LoginForm init");
}
});
Mã sẽ đi lên đến
console.log("onSubmitLogin");
Và sau đó dừng lại.
Mở mắt tôi sử dụng này:
var LoginForm = Ext.create("MyApp.view.LoginForm");
Ext.Viewport.add(LoginForm);
Vì vậy, làm thế nào tôi có thể nhận các giá trị?
Cảm ơn
Cảm ơn bạn đã đăng giải pháp của mình cho điều này! Nó đã giúp tôi rất nhiều. –