I have a scenario where a graph is built inside a modal. The graph has a callback function for clicking uppon the bars, so it brings the object like this:
{x: 'label', value: "value"}
Everytime I call the modal, it calls a function that clears the graph container div with $("#graph_div").empty();
and rebuild it with data coming from an AJAX request
Like:
new Morris.Bar({options}).on('click', function(a,b){ ... });
The fact is this onClick event is being stacked, even though I clear the #graph_div with the empty method. After a couple of hours identifying the reason for the response of the click coming with some stacked objects which the amount increases everytime I open the modal, I ended up adding a:
$("#graph_div").unbind('click'); everytime I build another Morris Bar graph.
Is this the standard behavior or is it a bug?
Thanks for the great project you created by the way, it's helping so much and is an amazing graph framework!
Hello, for me it is a bit overkilling to destroy your <div>. Just use the function setData(new_data), this will refresh your chart with the latest data and the click function would still work well.
Hello.
I have a scenario where a graph is built inside a modal. The graph has a callback function for clicking uppon the bars, so it brings the object like this:
{x: 'label', value: "value"}
Everytime I call the modal, it calls a function that clears the graph container div with
$("#graph_div").empty();
and rebuild it with data coming from an AJAX requestLike:
new Morris.Bar({options}).on('click', function(a,b){ ... })
;The fact is this onClick event is being stacked, even though I clear the #graph_div with the empty method. After a couple of hours identifying the reason for the response of the click coming with some stacked objects which the amount increases everytime I open the modal, I ended up adding a:
$("#graph_div").unbind('click');
everytime I build another Morris Bar graph.Is this the standard behavior or is it a bug?
Thanks for the great project you created by the way, it's helping so much and is an amazing graph framework!