Skip to content

Instantly share code, notes, and snippets.

@zoghal
Created August 5, 2012 10:13
Show Gist options
  • Save zoghal/3263654 to your computer and use it in GitHub Desktop.
Save zoghal/3263654 to your computer and use it in GitHub Desktop.
jQuery.event.special.contentchange
var interval;
jQuery.fn.contentchange = function(fn) {
return this.bind('contentchange', fn);
};
jQuery.event.special.contentchange = {
setup: function(data, namespaces) {
var self = this,
$this = $(this),
$originalContent = $this.text();
interval = setInterval(function(){
if($originalContent != $this.text()) {
$originalContent = $this.text();
jQuery.event.special.contentchange.handler.call(self);
}
},500);
},
teardown: function(namespaces){
clearInterval(interval);
},
handler: function(event) {
jQuery.event.handle.call(this, {type:'contentchange'})
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment