2

Possible Duplicate:
Detect element content changes with jQuery

I am trying to modify the selected option in a select that appears in a module window after a file is uploaded. I have yet to find a way to hook into the end of this ajax callback. So I am wondering if there is a way to monitor the parent div for content changes and then activate it on that.

I don't think this is possible, but I wanted to see if anyone else knew better than me.

I am using Drupal 6 and jQuery 1.3 on this site with a lot of modules.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Patrick
  • 3,302
  • 4
  • 28
  • 47
  • There are no generic events for div contents changing that are widely supported that I'm aware of. If you post the ajax code, there should be a way to know when that event has completed. – jfriend00 Feb 10 '12 at 21:02
  • 1
    Try having a look at this, seems to be what you are after: http://stackoverflow.com/questions/1091661/detect-element-content-changes-with-jquery – twilson Feb 10 '12 at 21:04
  • I figured as much. I have never heard of such a thing, but I had to ask. – Patrick Feb 12 '12 at 20:32

1 Answers1

3

DOMSubtreeModified. But they are deprecated.

For your case, it's better to intercept the AJAX request. This can be done in this way, without side effects:

(function($) {
    var $ajax = $.ajax;
    $.ajax = function(url, settings) {
        // Detect something, See http://api.jquery.com/jQuery.ajax/
        // If settings does not exist, then settings = url

        $ajax.call(this, url, settings); // Call normal AJAX thing
    };
})(jQuery);

Instead of intercepting all AJAX requests, you can also add an ajaxComplete event.

Community
  • 1
  • 1
Rob W
  • 341,306
  • 83
  • 791
  • 678
  • Thanks, this did it. I actually used your ajaxComplete suggestion. Perfect. Thanks again! – Patrick Feb 12 '12 at 20:44
  • I apologize. I put in the fix a few days ago and I confused this with another. I have adjusted my comment and given you credit for the fix. – Patrick Feb 12 '12 at 20:45