well, you can do the following
instead of writing
myelement.on("click", function(d,i) { /* does stuff */ });
you can write:
myelement.on("click", action);
and then
function action(d,i) { /* does stuff */ }
and subsequently call the function action from anywhere.
by the way, if you don't need to make reference to the data underlying your element or to its rank among similar element feel free to drop the (d,i) altogether. (i.e. function action() {...})