dongsuo0517 2013-04-09 06:50
浏览 100
已采纳

动态地向jQuery accordion部分添加内容

Title may suggest hint of a duplicate but problem is certainly not.

If it is a duplicate then please close it by posting relevant link to problem.

Now here is a description of my problem ->

I have created some html that look like this (This is just a small part of very big code) ..

enter image description here

Html contents are as follows : -

<div class="s">
    <div class="bmargin">
        <label for="sip" > Source IPv6 Address </label>
        <input type="text" name="sip" id="sip" required  placeholder="hello" autofocus/>
    </div>

    <div class="bmargin marginl">
        [Default : Link-layer]
    </div>

    <div class="bmargin">
        <label for="dip"> Destination IPv6 Address </label>
        <input type="text" name="dip" id="dip" placeholder="FF02::1"/>
    </div>

    <div class="bmargin marginl">
        [Default : All Node Multicat Address]
    </div>
  </div>

Now I have also created an accordion which would show up when clicking on advanced radio button :-

enter image description here

Accordion Jquery code is shown below :

 $(document).ready(function() {
    $("#stack").accordion({ heightStyle:"content", fillspace: true,
                                    icons: {'header': 'ui-icon-plus', 'headerSelected':    
     'ui-icon-minus'},collapsible: true, active:false});

HTML for the accordion contents :

<div class="advanced" id="stack">

<h3> <a href="#"> Network Interface Layer </a> </h3>
<div class="nlayer">
    This section is reserved for future
</div>

<h3> <a href="#" id="ilayer"> Internet Layer </a></h3>
<div class="ilayer">
<!--    <?php // require 'common_ilayer.html' ?> 
-->
</div>

<h3> <a href="#"> Transport Layer </a></h3>
<div>reserved for future</div>

<h3> <a href="#"> Application Layer </a></h3>
<div>reserved for future</div>

</div>

what I need is that I want to display same html div class="s" which was showing up initially in place of that php require 'common_ilayer.html' to appear when click on Internet layer.

What I need to achieve is something like this (Image shown below).. but without creating any duplicate node. At first place php require/include seems like working but that would indeed create duplicate code and server may become confuse on posting as there will be two elements with same ID.

enter image description here

I also tried this jQuery code but that did not help

 $('#ilayer').live("click",function(){
            $(".s").show();
    });

Note : Please do not suggest me to add different IDs to elements and include them by php. I want same contents to appear with all fields same in accordion Internet layer section which were appearing in basic section of tool.

Any help appreciated ...

Thanks

  • 写回答

2条回答 默认 最新

  • douzhi19900102 2013-04-09 07:17
    关注

    Leave your #ilayer empty on page load.

    Move the div.s node when clicking on the checkboxes :

    $('#basic').click(function(){
        var $div = $('div.s');
        $('#basicDialog').append( $div );
    });
    
    $('#advanced').click(function(){
        var $div = $('div.s');
        $('#ilayer').append( $div );
    })
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用