简体   繁体   English

通过jQuery Mobile手风琴可将文档准备就绪,相当于Ajax加载的内容

[英]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. 就像超长标题所暗示的那样,我需要一个与jQuery Document Ready等效的东西,该东西可以与通过jQuery Mobile手风琴/可折叠的ajax加载的动态加载内容一起使用。

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. 无法将JavaScript添加到实际的标记本身(由于CMS),因此必须通过全局js文件加载。
  2. $(document).ready() won't work because it's not technically the document that we're waiting to load. $(document).ready()无法使用,因为从技术上讲,它不是我们等待加载的文档。
  3. $('div#id').load() doesn't seem to work. $('div#id').load()似乎不起作用。
  4. $('div#id').ready() seems to run anytime the actual page is loaded, regardless of whether the collapsible content is run. $('div#id').ready()似乎在加载实际页面的任何时间运行,无论是否运行可折叠的内容。

This is kind of a shot in the dark, but anything you guys can help with, I'm grateful for :). 这是在黑暗中拍摄的照片,但是你们可以提供任何帮助,我非常感激:)。

Thanks 谢谢

Use .ajaxComplete() 使用.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) {

});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM