PDA

View Full Version : Problem in adding listeners to events



erfaan
19 Apr 2007, 11:03 PM
Hi,
I can successfully add


dialog.addListener('hide', this.myFunc);

but whenever I try to add listeners for other events like


dialog.addListener('move', this.myFunc);
dialog.addListener('resize', this.myFunc);
dialog.addListener('show', this.myFunc);

I get following error .


'fireFn' is null or not an object

Please help me out.

Thanks,

Animal
19 Apr 2007, 11:52 PM
Post your page code.

erfaan
20 Apr 2007, 12:32 AM
Thanks for your quick reply. Here is the code I am using.


function ExtJsWindow(showBtnId, dialogId)
{
var dialog, showBtn;

return {

init : function()
{
showBtn = Ext.get(showBtnId);
showBtn.on('click', this.showDialog, this);
},

showDialog : function()
{
if(!dialog)
{
dialog = new Ext.BasicDialog(dialogId, {autoTabs:false, proxyDrag:true, shadow:true });

//dialog.addListener('move', this.myFunc);
//dialog.addListener('resize', this.myFunc);
//dialog.addListener('show', this.myFunc);
dialog.addListener('hide', this.myFunc);
}

dialog.show(showBtn.dom);
dialog.toFront();
},

myFunc : function()
{
alert("myFunc()");
}
};
}

Animal
20 Apr 2007, 1:15 AM
How and where are you using that? Because that's not a valid constructor. It's a singleton creation function.

Because I think it's a scope issue. If you stop in Firebug at the "addListener" line, what is "this", and does it have a "myFunc" property?

erfaan
23 Apr 2007, 3:08 AM
At last I figured out the bug today. I was trying to use ext-js in my ASP.NET project. And the whole code to generate dialogs was so much complex that I could not post that all and waste your time in understanding ASP.NET code.

You were right, It was a scope problem. I was not sending the second argument of onReady. Now it is working fine.

Thanks for your support