Object function has no method defer
Asked Answered
B

3

6

I'm try to render a progress bar in grid (Ext JS), and get this error:

Object function has no method defer

What is this "magical" method? What does it do? And why is it not found? Code:

renderer: function (value, meta, rec, row, col, store){
    var id = Ext.id();
    (function(){
        new Ext.ProgressBar({
            renderTo: id,
            value: 0.5
        });
    }).defer(25);
    return '<span id="' + id + '"></span>';
}
Breger answered 16/4, 2011 at 19:17 Comment(0)
S
10

The function defer is used to delay a function call by X milliseconds. Try a syntax like this:

Ext.Function.defer(function(){
    new Ext.ProgressBar({
        renderTo: id,
        value: 0.5
    });
}, 25);

That should work according to ExtJS API documentation.

Spaceman answered 17/4, 2011 at 5:15 Comment(1)
If you're using Sencha Touch, it would be Ext.defer(function () { ... }, 25); -- in case anyone spent as long hunting this down as I just did!Cesaro
O
2

Which version of ExtJS are you using?

Are you sure you have all the ExtJS loaded? Do you get the same error when you run this code from browser command line:

(function(){alert("Hello");}).defer(1000);
Oscoumbrian answered 16/4, 2011 at 21:7 Comment(2)
Im using just examples bootstrap.js. Other samples work, but yes in command line folowing code not working - same error. May be i need some of Ext.require() ?Breger
A lot has changed in ExtJS 4 - don't hope the examples for previous version to work. No more are native JavaScript objects extended. defer() is now part of Ext.Function, not of native Function. Try the example posted by Tommy.Oscoumbrian
Y
0

Ext.defer or Ext.function.defer is a function similar to javascript setTimeout function.

http://astutejs.blogspot.in/2015/06/extjs-what-is-extdefer.html

Yoghurt answered 4/7, 2015 at 3:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.