简体   繁体   中英

How to remove a YUI Chart from a page

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("<exception>" + e + "</exception>");     
}

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM