views:

102

answers:

1

I need to create and remove YUI charts from a page. To remove, I am doing $('.chart').remove() to get rid of the containing DIV. However, this raises a null reference exception in this script: try { document.getElementById("yuiswf1").SetReturnValue(_flash_toXML(YAHOO.widget.SWF.eventHandler("yuiswf1",({category:"info",message:"resize (width: 0, height: 0)",type:"log"}))) ); } catch (e) { document.getElementById("yuiswf1").SetReturnValue("" + e + ""); }

I assume YUI attaches this code for some event handler which is failing since the DIV has been removed.

How can I remove a YUI chart without causing this exception?

+1  A: 

Try calling the destroy method on your chart object before removing its parent div.

mychart.destroy(); (assuming your variable for the chart is mychart)

If you still have issues, you can try posting back on yui library's forum. http://yuilibrary.com/forum/

Tripp

tripp