...oh hey. I just thought of something... It can be done using eval. (feeling kinda sick just by saying that)
Javascript code:
var plusWnd = $(MsgPlus).CreateWnd("interface.xml", "yiew", 0);
//[...]
$.wrappers.MsgPlus.CreateWnd = function (XmlFile, WindowId, Options) {
var toEval = "var On" + WindowId + "Event_Cancel = function (plusWnd) { $.trigger(plusWnd, '" + WindowId + "Event_Cancel', plusQuery.$A(arguments)); };";
toEval += "var On" + WindowId + "Event_Destroyed = function (plusWnd, exitCode) { $.trigger(plusWnd, '" + WindowId + "Event_Destroyed', plusQuery.$A(arguments)); };";
//etc
(1, eval)(toEval); //indirect call to eval; makes it evaluate in the global scope
this.original.CreateWnd(XmlFile, WindowId, Options);
}
This would work, no?