Question

I'm trying to use Ext.util.DelayedTask to make some timed functions go off. I'm getting the error Uncaught TypeError: undefined is not a function call. It's coming from line 126 of DelayedTask.js in the Sencha source code. Click here to see the source.

Here is the code I wrote which runs the tasks.

var appView = Ext.ComponentQuery.query('.meterreadings_main')[0];
var meterList = Ext.ComponentQuery.query('.mbList[alias="meterListObject"]')[0];

var taskOne = Ext.create('Ext.util.DelayedTask', {
    scope: this,
    fn:function() {
        appView.pop();
    }
});

var taskTwo = Ext.create('Ext.util.DelayedTask', {
    scope: this,
    fn:function() {
        meterList.select(meterStore.getCurrentRecordIndex());
    }
});

var taskThree = Ext.create('Ext.util.DelayedTask', {
    scope: this,
    fn:function() {
        meterList.config.itemTapHandler(null,meterStore.getCurrentRecordIndex(), null,
            meterStore.getCurrentRecord(), null, null);
    }
});

appView.pop();
taskOne.delay(500);
taskTwo.delay(1500);
taskThree.delay(2500);

See anything wrong?

Was it helpful?

Solution

Even though the ST2 docs show that you can create a delayed task like how you are currently doing, you actually need to do it the following way:

var taskOne = Ext.create('Ext.util.DelayedTask', function() {
    console.log('delayed task');
}, this);

Here are the parameters you can pass, you'll see I already included the scope above:

Parameters

fn : Function
The default function to call.

scope : Object
The default scope (The this reference) in which the function is called. If not specified, this will refer to the browser window.

args : Array
The default Array of arguments.

Good Luck!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top