I attach an onmouseout event to a Raphael circle element like this:
(function(el,iElPos,col){
el.mouseout(function elmouseout(){el.animate({"fill":col,"r":ELEMENT_RADIUS},150);
alert("first");
fadeTag();
});
)(c,i,elementColour);
c is the element. I then later wish to disconnect the event and attach another thuswise:
(function (el){
el.attr("fill",EXCLUDED_COLOUR);
el.unmouseout(elmouseout);
el.mouseout(function elmouseout(){
alert("second");
el.animate({"fill":EXCLUDED_COLOUR,"r":ELEMENT_RADIUS},150);
fadeTag();
});
})(setMainSeries[iPos]);
But this attaches both events. Both alerts are firing, the later-attached event fires first. I want to disconnect the first event totally. Am I using unmouseout() incorrectly?
UPDATE
I tried suggestions from echo-flow and lincolnk but neither worked. I think echo-flow's may be more likely to work. I broke out the function as suggested like so...
function elmouseoutDefault(el){
el.animate({"fill":ELEMENT_COLOUR,"r":ELEMENT_RADIUS},150);
alert("first");
fadeTag();
};
then attached the event like this as I created each element...
el.mouseout(elmouseoutDefault);
However this failed as I am not passing el
. So I changed it to...
el.mouseout(elmouseoutDefault(el));
This seems to call elmouseoutDefault
as it is being added. I only want it to trigger on the mouseout event.