jaf*_*ffa 5 sencha-touch sencha-touch-2
我希望能够在商店同步成功完成后向用户显示消息.但是,似乎没有任何方法可以使用回调或同步调用它.我有点惊讶这不是开箱即用,因为它一定是一个常见的问题.
这有什么解决方法吗?
我们花了很长时间才找到适当的解决方案。最后,我们向商店的写入事件添加了监听器,这似乎工作正常。由于经常需要它,因此已将其添加到商店原型中
Ext.data.Store.prototype.syncWithListener = function(onWriteComplete, syncMethod) {
this.on('write', onWriteComplete, this, {single:true});
var syncResult = syncMethod ? syncMethod.apply(this) : this.sync();
if (syncResult.added.length === 0 &&
syncResult.updated.length === 0 &&
syncResult.removed.length === 0) {
this.removeListener('write', onWriteComplete, this, {single:true});
onWriteComplete(this);
}
return syncResult;
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2344 次 |
| 最近记录: |