我有一个ScriptTagProxy,我能够接收数据,但现在我想更新记录。我指定了一个url,但只有一个url。我必须使用此网址处理所有操作(读取,更新,创建,删除)吗? 如果是:该动作如何应用于该网址? 如果没有:我如何指定更多的网址?Sencha Touch:用于创建/更新功能的ScriptTagProxy url
这里是我到目前为止的代码:
app.stores.entries = new Ext.data.Store({
model: "app.models.Entry",
storeId: 'app.stores.entries',
proxy: {
type: 'scripttag',
url: 'http://myurl.de/getEntries.php',
extraParams: {
username: Ext.util.JSON.decode(window.localStorage.getItem('settings')).username,
password: Ext.util.JSON.decode(window.localStorage.getItem('settings')).password
},
reader: {
type: 'json'
},
writer: {
type: 'json'
}
}
});
我的文档阅读,你可以通过一个配置对象模型来configurate代理的保存功能。
所以我尝试以下操作:
entry.save({
url: 'http://mysite.com/updateEntry.php',
extraParams: {
username: Ext.util.JSON.decode(window.localStorage.getItem('settings')).username,
password: Ext.util.JSON.decode(window.localStorage.getItem('settings')).password,
entry: entry
},}
正如你看到的有指定的网址。 但我仍然收到错误: 未捕获错误:您正在使用ServerProxy,但尚未向其提供url。 );
相同的行为使用AjaxProxy或RestProxy例如:(
您定义的actionMethods是默认值,所以这不会改变任何东西。我只想.save()模型“实例”。这是发生错误的地方。我可以做一个sync(),但是这不会调用任何可以在后端更新数据的url。 非常感谢您的回答,但它并没有解决问题:( – hering 2011-04-14 06:18:48
我发现即使它们是默认设置,但直到我明确设置它们时,它才真正以这种方式工作。做了同步()它仍然只是发送一个POST。一旦我设置它们,我开始得到DEL和PUT请求。 – ballmw 2011-04-14 10:40:44