Raphael paper with id
I have a situation where I am adding multiple papers to my page. I have drawn certain rect and path objects on each. I know how I开发者_开发技巧 can give id to each such object, but i haven't seen any example for adding an id to the paper itself. I need to change the objects on click event of a rect within the paper. For this I want to clear the old objects and draw new ones. The problem is that i am reusing the variable for the paper. Hence the variable contains a reference to the most recent paper which is not the one i want. Due to all this I was wondering if I could attach an id to each and retrieve the paper and then use it. Any suggestions are welcome. Kavita
Hi, I am unable to get the paper object from the shape that has been clicked!! this.paper, $(this).paper dont work. Any help is appreciated...
Take a look at this fiddle. If you are setting up the event handler using something like
$(object.node).mouseover(function() {...})
when you refer to this
in the function, it refers to the DOM node, not the Raphael object. Consequently, you cannot access Raphael's properties or methods. The only way I have been able to get this to work is by passing in the Raphael object in the event data like so:
$(object2.node).mouseover({rObj: object2},
function (e) {
e.data.rObj.paper.clear();
});
精彩评论