Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Document Ready equivalent for ajax-loaded content via jQuery Mobile accordion

As the super-long title suggests, I'm needing something of a jQuery Document Ready equivalent that will work with dynamically-loaded content that's loaded via ajax in a jQuery Mobile accordion/collapsible.

We have a few things that WON'T work as well:

  1. Can't add javascript to the actual markup itself (due to CMS) so it has to be loaded via the global js file.
  2. $(document).ready() won't work because it's not technically the document that we're waiting to load.
  3. $('div#id').load() doesn't seem to work.
  4. $('div#id').ready() seems to run anytime the actual page is loaded, regardless of whether the collapsible content is run.

This is kind of a shot in the dark, but anything you guys can help with, I'm grateful for :).

Thanks

like image 444
Will Avatar asked Jan 18 '12 15:01

Will


1 Answers

Use .ajaxComplete()

$(document).ajaxComplete(function(e, xhr, settings){

});

If you want to do something when document has something new added then:

$(document).on('DOMNodeInserted', function(e) {

});
like image 129
Muhammad Usman Avatar answered Nov 19 '22 14:11

Muhammad Usman