我有一个带有商店,模型和一些视图的控制器.
我需要在控制器中监听存储beforesync和write事件,但我不知道如何在controllers control-function中设置这些监听器.
我的商店看起来像这样:
Ext.define('DT.store.UsersStore', {
extend : 'Ext.data.Store',
model : 'DT.model.User',
id : 'myStore'
autoSync : true,
proxy : {
type : 'ajax',
api : {
read : '/load_entries',
update : '/update_entry'
},
reader : {
type : 'json',
root : 'user',
successProperty : 'success'
}
}
});
Run Code Online (Sandbox Code Playgroud)
现在我尝试听我的控制器中的事件:
...
init : function () {
this.control({
'myStore' : {
beforesync : this.doSomething,
write : this.doSomethingElse
}
});
},
...
Run Code Online (Sandbox Code Playgroud)
我的预期结果是,在触发事件时将执行函数.但此时他们被解雇时没有任何反应.
我怎样才能让它发挥作用?