My app is using Raphaël to drop a collection of objects onto a page, each with a click
handler bound that uses data attached to the object when it was loaded in
I found that first finding the raphael object, then traversing the DOM allowed me to find the functions of their event handlers. For mine, the click event was the 0th event.
So to trigger it all I did was:
raphobj.events[0].f();
Be careful though, because if in the click event you reference 'this' it won't work.
You can add this custom method to your raphael elements:
Raphael.el.trigger = function(eventName){
for(var i = 0, len = this.events.length; i < len; i++) {
if (this.events[i].name == eventName) {
this.events[i].f.call(this);
}
}
}
You can use it just like:
var r = paper.rect(0,0,100,100).attr({"fill": "#f00"});
r.click(function(){
this.attr("fill": "#0f0");
});
r.trigger("click");