Q:

jQuery Plugin event order

I'm using cleditor a jQuery plugin that is a WYSIWYG editor. Unfortunately, I've run across a bug in IE involving an event handler. When the user clicks a button before focusing the textbox, they get an error message. If they have focused the textbox, ever, it's fine, and on other browsers it's not problem at all. I don't want to edit the plugin because I want to be able to update it later, and I'm not 100% it's the plugin's fault (people who author plugins tend to be smart). In IE the plugin's event handler runs before my custom handler, at least while debugging. So...
Q: How can I ensure my custom event handler runs before the plugin's event handler without editing the plugin?

A:

jQquery bound events are triggered first on the triggered element and it bubbles up to it's parents one by one, and on each element it will trigger events in the order that they were bound on that element.
Edit:
To change the order of those events, simply modify the events object stored on the element. Below is a demo with a fiddle. The last event will get triggered first even though it was bound last.
http://jsfiddle.net/FqafW/
$("#demo").bind('click',function(){
   console.log('event 1'); 
}).bind('click',function(){
   console.log('event 2'); 
}).bind('click',function(){
   console.log('event 3'); 
}).bind('click',function(){
    console.log('my event');
});

var clickEvents = $("#demo").data("events").click;
console.log(clickEvents);
var myClickEvent = clickEvents.pop();
console.log(myClickEvent);
console.log(clickEvents);
clickEvents.unshift(myClickEvent);
console.log(clickEvents);

