1
我很奇怪,爲什麼我不能做到以下幾點:煎茶觸摸model.save()和更新,無需額外負荷
newChallenge = Ext.create('App.model.User', {name:'donald'});
newChallenge.save();
*** After another user action ***
newChallenge.set('name','george');
newChallenge.save();
我遇到的問題是,第二保存/更新甚至沒有觸發AJAX補丁/張貼到服務器後第一個,並沒有設置名稱爲'喬治'
我沒有看到日誌中的任何錯誤或數據庫中的更新。
型號:
Ext.define('App.model.User', {
extend: 'Ext.data.Model',
requires: [
'Ext.data.identifier.Uuid'
],
config: {
identifier: 'uuid',
fields: [
{ name: 'id', type: 'auto', persist: false },
{ name: 'name', type: 'string' }
]
proxy: {
type: 'rest',
api: {
create: App.util.Config.getApiUrl('user_profile'),
update: App.util.Config.getApiUrl('user_profile'),
read: App.util.Config.getApiUrl('user_profile')
},
reader: {
type: 'json'
},
writer: {
type: 'json-custom-writer-extended',
writeAllFields: true,
nameProperty: 'mapping'
}
}
}
});
服務器響應(TastyPie):
{
"name":"george",
"id":35,
"resource_uri":"/app/api/1/user/35/",
"start_date":"2013-08-06T14:49:11.030298"
}
謝謝你,史蒂夫
感謝rixo。我根據你的建議更新了這個問題。第二次保存是在第二次提交後發生的,所以同步阻塞不是問題。錯誤情況也在那裏,爲了清晰起見,僅僅省略了。 – daxiang28