Sign in to follow this  
RDEN

Js error on IE8 when calling .dispose()

Recommended Posts

Hi,

 

I encountered the following js error (FusionCharts.HC.js) when trying to dispose charts on IE8 from ajax rendered tabs (richfaces tabs) :

Unable to get property 'removeChild' of undefined or null reference

To give a little more context, i have some ajax rendered tabs each of them rendering some charts.

When a tab switch is performed, current tab charts are rendered and i need to dispose previous ones.

 

I am checking that the FusionCharts instance exists before calling .dispose() but it doesn't help :

var chart = FusionCharts(chartId);
if(!!chart)
   chart.dispose();

Indeed the FusionCharts instance exists but the associated html5 markup is no longer in the DOM (due to the ajax re-render) and it seems that the part of the dispose method responsible of removing the markup from the DOM is still called.

Debugging reveals that the error comes from the line 'this.canvas.parentNode.removeChild(this.canvas);' (FusionCharts.HC.js) where 'this.canvas.parentNode' is null :

b.prototype.remove =
     function () {
        K("raphael.remove", this);
        this.canvas.parentNode.removeChild(this.canvas);
        for (var c in this) this[c] = typeof this[c] == "function" ? b._removedFactory(c) : null;
           return !0
      };

Maybe some tests can be added to be sure that chart markup is present before trying to remove it ?

temporarily bypassed the problem by adding a null check before the removeChild() call.

Also there is no error on chrome nor firefox.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this