bharatm

Hi,

I am trying to create a gadget which has a media player in it using the OBJECT tag.

Is there any event which is raised when a user removes the Gadget from his Live page

i need to write some code when the user removes the gadget by clicking on the close (x) button. but i am not able to find anything about this event..

There is an event named "onModuleRemovedEvent" but i am not sure how to use it..

Thanx for the help in advance..

Regards

Bharat T. Motwani



Re: Web Gadget Development Gadget Remove issue

Chris Butler

Hi Bharat.

If you don't mind me asking, why do you need to know when the gadget is removed

I would think you could use the unload event, but that would be triggered every time that the person browses away from the page or closes the browser.






Re: Web Gadget Development Gadget Remove issue

bharatm

Hi Chris,

I need to stop the media player if its already running when the user removes the gadget.
For doing this i think i will need to use the remove or the unload event as u suggested.

I tried the unload even as follows.. but when i remove the unload event is not invoked..
This even is invoked when i close the browser. or browse from that page.
But i want to catch the remove module event..

this.Output = function()

{

var currWindow = window;

currWindow.attachEvent("onbeforeunload",fnWindowOnUnload);

//currWindow.onunload = fnWindowOnUnload;

}

function fnWindowOnUnload(){

var objMedia;

objMedia = document.getElementById("media1");

objMedia.controls.stop();

alert("Current. Window Unloaded");

}

I browsed thro. the js files and i found one event named "onModuleRemovedEvent"
But how do i handle this event..

Thanx..

Bharat T. Motwani





Re: Web Gadget Development Gadget Remove issue

ToddOs

Why not use the dispose() function That should be called when the gadget is disposed (removed from the page, or you navigate away from the page). You should be clearing up any references and bindings in dispose() already lest you leak memory, so if you need to stop the player you should do it there as well.





Re: Web Gadget Development Gadget Remove issue

bharatm

hi Todd,

I used the dispose function but its not getting called when the gadget is removed from the page..
The dispose func. is being called when i browse to some other page or close the browser.

But its not being called on removal of the gadget by clicking on the x button.

I checked the js files and found out that the removeNode method is called for the div which holds
the gadget..


Thanx..

Bharat T. Motwani