1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
    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'})
        }
    };