PDA

View Full Version : Delayed Listener Bug



n01champion
21 Feb 2007, 11:06 AM
My Code:

ds.on('load', foo, this, {delay: 250});

Bug:

h has no properties
(ext-all.js : line 18) - Ext.util.Observable

jack.slocum
21 Feb 2007, 11:30 AM
Are you sure foo exists? That message means your handler function is undefined.

I just tested it locally and it worked as expected. When I passed in an undefined handler function, I got the same message as you.

n01champion
21 Feb 2007, 12:02 PM
ok i get it..

I tried doing this and didnt work:
ds.on('load', plantGrid.getView().autoSizeColumns(), this, {delay: 250});

the reason why i was trying to do it this way was because when you put autoSizeColumns in the the configuration of the grid.. it loads to fast and doesn't size properly.

it works now without the delay by doing this:

ds.on('load', adjustGrid, this, {delay: 250});

function adjustGrid(){
plantGrid.getView().autoSizeColumns();
}

jack.slocum
21 Feb 2007, 12:09 PM
The problem is you are executing the function immediately (you have "()" at the end) rather than passing a callback. Also, your scope with be wrong. Here's your original code edited:

var view = plantGrid.getView();
ds.on('load', view.autoSizeColumns, view, {delay: 250});

Here we are passing a function (rather than calling the function) and we are setting the scope to the "view" object so that within autoSizeColumn the this reference with be correct.

n01champion
21 Feb 2007, 12:15 PM
NICE!!!..

I never looked at it way. It works perfectly.

THANKS!!

Will be tipping you soon.