问题
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:
- Can't add javascript to the actual markup itself (due to CMS) so it has to be loaded via the global js file.
$(document).ready()won't work because it's not technically the document that we're waiting to load.$('div#id').load()doesn't seem to work.$('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
回答1:
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) {
});
来源:https://stackoverflow.com/questions/8912411/document-ready-equivalent-for-ajax-loaded-content-via-jquery-mobile-accordion