override html()

override html()

Is it possible to "override"/"hook"/"replace" the html() method on particular elements, and if so, how?  Or, are there any events raised when the html is changed by a call to html()?

The reason I am asking is that I would like to detect when html() is called on an element in order to do some pre-processing before the html is changed and some post-processing after the html has changed.

Further background: I am creating a ui widget myDialog, extending ui.dialog.

 var myDialog = $('<div></div>').myDialog({...});

And if the user loads or changes the content with
 myDialog.html('here is some content');
or
 myDialog.load(url);


then myDialog would like to detect that change and do the pre- and post-processing.  If possible, I would like to accomplish that in myDialog's _create (or possibly _init) method.

My initial naive approach was to, in _create(), replace self.element.html method with a new method that does the pre-processing, calls the original html method and does the post-processing.  But, of course (?), that only replaces the html method of that particular wrapper (self.element), and the user has his own wrapper object.  So when the user calls myDialog.html(...) then the orginal html method that jQuery provides is still called.