如何每隔X秒重新加载一次?

时间:2013-01-19 09:46:35

标签: extjs

我正在使用ExtJS 4 MVC。

有没有办法每隔X秒重新加载一次?

我想把代码放到Controller

2 个答案:

答案 0 :(得分:5)

setInterval(function(){
    // Use Ext.getStore to reference your store from the controller
    var myStore = Ext.getStore('YourStore');
    // Pass in an object of the changes you want to be made to the store
    myStore.proxy.extraParams = { key:'sencha'}; // replace with your own object
    myStore.load();

},3000);

答案 1 :(得分:0)

在Extjs中的FYI可以通过Ext.util.TaskRunner实现。 示例代码:

var runner = new Ext.util.TaskRunner(),
clock, updateClock, task;

clock = Ext.getBody().appendChild({
    id: 'clock'
});

// Start a simple clock task that updates a div once per second
updateClock = function() {
    clock.setHtml(Ext.Date.format(new Date(), 'g:i:s A'));
};

task = runner.start({
    run: updateClock,
    interval: 1000
});