动态添加的内容不再打开手风琴 [英] Dynamically added content no longer opens accordion

查看:162
本文介绍了动态添加的内容不再打开手风琴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在模式窗口中打开的手风琴.手风琴不再工作,因为我现在正在动态地创建模式的内容,而以前,数据是用HTML硬编码的,所以一切都按预期运行.

I have an accordion that opens within a modal window. The accordion is no longer working because I'm creating the content for the modal dynamically now, where before, the data was hard coded in my HTML, so everything functioned as expected.

这是我现在要进行AJAX通话的条件:

This is what I have now for my AJAX call:

      ...
      success : function(data)
      {
        $('<div/>', {
          id:'modal'
        }).html(data).appendTo('body');

        $('#modal').popup({
          autoopen  : true,
        });
      },

这是手风琴的呼唤:

$('.accordion').accordion({
    collapsible: true
});

模式窗口不会打开,但是手风琴不会折叠或打开.我还可以看到,没有与手风琴相关的事件,而且在更改之前没有.

The modal window opens no problem, but the accordion does not collapse or open anymore. I can also see that there are no events tied to the accordion, and before the changes, there were.

因为我的模态的内容现在正在动态创建,有没有办法让手风琴再次起作用?

Because the content for my modal is being created dynamically now, is there a way to get the accordion functioning again?

推荐答案

每次编辑时都必须刷​​新手风琴.

You have to refresh the accordion every time you do an edit.

$('.accordion').accordion("refresh");

这篇关于动态添加的内容不再打开手风琴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆