doutandusegang2961 2013-07-27 02:10 采纳率: 0%
浏览 62
已采纳

jquery手风琴不起作用

I use accordion box comes from Jquery UI. It doesnt work.

  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

Here is the event handler I use accodion box

$("#skillcat").click(function(e) {
                //var submit_val = new Array();
                //$('#accordion1').accordion('destroy');
                e.preventDefault();
                var ids = [];
                var el = $('[name*=check_subjects]:checked'); //Get all checked Checkboxes
                el.each(function () {
                    ids.push($(this).attr('id')); //get the Id from each checkbox
                });

                $.ajax( {
                type : "POST",

                dataType : "json",
                //
                url : "./wp-admin/admin-ajax.php",
                data : {
                    action : 'each_category',
                    check_subjects : ids
                },
                success : function(data) {
                            alert(data);

                    $('#accordion1').html(data);
                    $("#accordion1").accordion({ active: 0 });
                    $("#accordion1").css("font-family", "'Trebuchet MS', Arial, Helvetica, sans-serif");
                    $("#accordion1").css("font-size", "0.9em");



                    }
            });
        });

place that I suppose to render accodion

   <div id="accordion1" >


    </div>

However, when I click the button first time I get the data to alert box. It render conent but it doesn't apply accodion box. I have another accordion on same page but it works.

If I click another button on same page and try submitting above button, I get data to alert but it won't render the html to browser.

where I have done the mistake?

Ajax is working.

Update

when I add this code

$('#accordion1').accordion('destroy');

before

$('#accordion1').html(data);

Accodion starts to work. But as usual it isnot working second time.

展开全部

  • 写回答

1条回答 默认 最新

  • doudundian9558 2013-07-28 03:58
    关注

    All jQuery UI plugins maintain state, such as the current option values, whether the plugin is enabled or disabled, which plugins have been initialized on the element, etc. This state persists from the time the plugin is instantiated on the element until it is destroyed, either explicitly by the user calling .pluginName('destroy') or by removing the element (or one of its ancestors) via .remove(). Because of this state management, you cannot instantiate the same plugin on an element multiple times, unless you destroy the plugin instance first.

    Please check following link for more inormation help link

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

悬赏问题

  • ¥50 数据库开发问题求解答
  • ¥15 安装anaconda时报错
  • ¥20 如何用Python处理单元格内连续出现的重复词语?
  • ¥15 小程序有个导出到插件方式,我是在分包下引入的插件,这个export的路径对吗,我看官方文档上写的是相对路径
  • ¥20 希望有人能帮我完成这个设计( *ˊᵕˋ)
  • ¥100 将Intptr传入SetHdevmode()将Intptr传入后转换为DEVMODE的值与外部代码不一致
  • ¥50 基于ERA5数据计算VPD
  • ¥15 寻找杂志《Tornatzky, L. G., & Fleischer, M. (1990). The Processes of Technological Innovation. 》
  • ¥15 前台多人编辑时怎么让每个人保存刷新都互不干扰
  • ¥20 如何用Python删除单元格内连续出现的重复词?
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部