【发布时间】:2012-02-25 08:07:13
【问题描述】:
我正在使用 Secha Touch 开发一个简单的表单。我为我的模型定义了一个 DataStore,如下所示:
App.stores.shopinglists = new Ext.data.Store({
model: 'ShopingList',
autoLoad: false,
proxy: new Ext.data.AjaxProxy({
type: 'ajax',
url: 'http://localhost:2795/ShopingListService/',
reader: {
type: 'json',
root: 'ResultData',
totalProperty: 'Total',
successProperty: 'Success'
},
writer: {
encode: true,
type: 'json'
}
})
});
视图加载正常,我可以看到项目列表并对其进行编辑。但是,当我单击更新按钮时,出现以下错误: 未捕获的错误:您正在使用 ServerProxy,但尚未为其提供 url。
我在这里缺少什么?代理已经定义了 url,但是当调用更新时,它是未定义的。
编辑:按钮只是调用一个控制器动作。
onSaveAction: function () {
var model = this.getRecord();
Ext.dispatch({
controller: 'ShopingLists',
action: (model.phantom ? 'save' : 'update'),
data: this.getValues(),
record: model,
form: this
});
},
控制器执行的代码是这样的:
update: function (params) {
debugger;
var tmpshopingList = new App.models.ShopingList(params.data);
var errors = tmpshopingList.validate();
if (errors.isValid()) {
params.record.set(params.data);
params.record.save();
this.index();
} else {
params.form.showErrors(errors);
}
},
【问题讨论】:
-
请张贴更新按钮执行的代码
-
您好:感谢您的重播。我将代码放在了我的第一个评论中。
标签: sencha-touch