I have to clear and redraw a raphael javascript main container. I've tried with
var paper = Raphael(10, 50, 320, 200); paper.remove(); // Doesn't work paper.node.removeNode(); //this neither paper.removeNode(); //this neither
Any idea?
I have to clear and redraw a raphael javascript main container. I've tried with
var paper = Raphael(10, 50, 320, 200); paper.remove(); // Doesn't work paper.node.removeNode(); //this neither paper.removeNode(); //this neither
Any idea?
Yes! you have to plough to the end of the docs..
(
function (local_raphael)
{
/*Put your little bit of Rap code in here*/
var paper = local_raphael(10, 10, 320, 200);
}
)(Raphael.ninja());
When you create a paper it creates a DOM object. You can access this with
paper.canvas
When you create a new Raphael object, you create a new DOM object and leave the original one alone! This is the best way to do it considering everything though. If you want to delete the canvas you only need to do the next command:
//Note: after calling this function the paper object will be useless!
//Make paper object null (or a new paper object) immediately!
function clearPaper(paper){
var paperDom = paper.canvas;
paperDom.parentNode.removeChild(paperDom);
}
Actually it's just come to my notice that there's the much easier paper.clear(); It's not documented.