How to use the Sencha ExtJS or Touch DelayedTask (example)

Here’s a quick example of how to use a Sencha ExtJS or Touch DelayedTask:

onMainViewportAfterRender: function(viewport, options) {
    var tabPanel = viewport.down('tabpanel');
    var task = new Ext.util.DelayedTask(function() {
        tabPanel.setActiveTab(0);
    });
    task.delay(250);
}

As shown, the first thing you do is create a task by giving a DelayedTask a callback function. Then you tell the task how long it should delay before executing.

There are better reasons to do this than what I’ve shown, but (a) this is a simple example, and (b) I have been having a hard time trying to set the active tab, and as a quickie bug fix for the moment, this works.

Note that you can also do this with plain old JavaScript and setTimeout, like this:

setTimeout(myFunction, 250);

Add new comment

The content of this field is kept private and will not be shown publicly.

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.