且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

JQuery用户界面手风琴无法正常工作与AJAX加载的内容

更新时间:2023-12-05 10:57:58

两件事情,首先你有一个额外的} 在脚本的末尾。

Two things, first you have an extra } at the end of your script.

二,手风琴内容不正确加载,因为手风琴的DOM元素是尚未加载(它们在你的AJAX调用加载),所以把下面的 SubMenuItemContent.php 文件:

Second, the accordion content isn't loaded correctly because the accordion DOM elements are not yet loaded (they are loaded in your AJAX call), so put the following your SubMenuItemContent.php file:

<script>
jQuery(document).ready(function($) {   

 $('.accordion').accordion({
  heightStyle: "content",
  active: false,
  collapsible: true
 });

})
</script>

要初始化加载的手风琴。

to init the accordion that is loaded.

另外,您可以尝试移动手风琴()打电话给你的成功回调里面,像这样:

Alternatively you could try moving the accordion() call inside your success callback like so:

success: function(result) {
 menuItemContent.html(result);
 $('.accordion').accordion({
  heightStyle: "content",
  active: false,
  collapsible: true
 });
}

不过,我有更多的成功与previous方法,无论出于何种原因。

But I've had more success with the previous method, for whatever reason.