1
我創建了一個MVC SenchaTouch項目。 我已經創建了一個示例應用程序,用戶將輸入用戶名和密碼並將其發送到Web服務。向我的基於MVC的Sencha Touch項目添加'Controller'類
用戶名和密碼字段假設在'VIEW'中,'發送給Web服務'功能應該在'CONTROLLER'中。
在我的程序中,發送到Web服務部分也存在於'VIEW'中,所以有人可以幫我編輯我的代碼,以便我可以在'發送到Web服務'功能'控制器'
下面的代碼
Ext.define('TU.view.Contact',{
extend:'Ext.form.Panel',
xtype:'contactform',
config: {
title:'Contact',
iconCls:'user',
url:'http://somesite.com/contact.php',
items: [
{
xtype:'fieldset',
title:'User Login',
items:[
{
xtype:'textfield',
name:'name',
label:'Name'
},
{
xtype:'passwordfield',
name:'password',
label:'Password'
}
]
},
{
xtype:'button',
text:'Send',
ui:'confirm',
padding:5,
handler:function(){
this.up(contactform).submit();
}
}
]
}
});
1.)我必須擺脫'處理程序:函數(){這個。(contactform).submit(); }'contactView.js'的代碼行? 2.)MyApp.controller.Main是Controller類的名字嗎? (我的控制器類被稱爲'myController.js')? – user1315906
1)由於您需要從控制器文件中調用Web服務代碼,因此您可以安全地從視圖中刪除該處理函數.... 2)'Main.js'是我的控制器文件的名稱。只需將它更改爲''myController.js''即可。 僅供參考,'MyApp'是我爲我的應用程序提供的示例名稱 –
我在alert /'Web服務代碼前往此處添加了一個alert語句alert('come here');'線沒有得到執行。任何線索? – user1315906