我已经尝试并试图弄清楚如何使手风琴在弹出窗口中工作。我似乎无法弄清楚。当手风琴不在弹出窗口内时,示例手风琴就可以正常工作。我在下面添加了一些示例代码。任何帮助表示赞赏。

<div class="hidden-md hidden-lg" style="float: right; padding: 15px 0px 15px 15px;">
<a data-placement="bottom" data-toggle="popover" data-container="body" type="button" data-html="true" href="#"><i class="fa fa-chevron-right"></i> FILTERED BY</a>


    <div id="popover-content" class="hide">

        <div class="panel-group" id="accordion">
            <!-- accordion 1 -->
            <div class="panel panel-primary">

                <div class="panel-heading">
                    <!-- panel-heading -->
                    <h4 class="panel-title">
                        <!-- title 1 -->
                        <a data-toggle="collapse" data-parent="#accordion" href="#accordionOne">
                            Collapsible Accordion 1
                        </a>
                    </h4>
                </div>
                <!-- panel body -->
                <div id="accordionOne" class="panel-collapse collapse in">
                    <div class="panel-body">
                        Lorem ipsum dolor sit amet, consectetur adipisicing elit,
                        sed do eiusmod tempor incididunt ut labore et dolore magna
                        aliqua. Ut enim ad minim veniam, quis nostrud exercitation
                        ullamco laboris nisi ut aliquip ex ea commodo consequat
                    </div>
                </div>
            </div>

            <div class="panel panel-success">
                <!-- accordion 2 -->

                <div class="panel-heading">
                    <h4 class="panel-title">
                        <!-- title 2 -->
                        <a data-toggle="collapse" data-parent="#accordion" href="#accordionTwo">
                            Collapsible Accordion 2
                        </a>
                    </h4>
                </div>
                <!-- panel body -->
                <div id="accordionTwo" class="panel-collapse collapse">
                    <div class="panel-body">
                        Change does not roll in on the wheels of inevitability,
                        but comes through continuous struggle.
                        And so we must straighten our backs and work for
                        our freedom. A man can't ride you unless your back is bent.
                    </div>
                </div>

            </div>

            <div class="panel panel-warning">
                <!-- accordion 3 -->

                <div class="panel-heading">
                    <h4 class="panel-title">
                        <!-- title 3 -->
                        <a data-toggle="collapse" data-parent="#accordion" href="#accordionThree">
                            Collapsible Accordion 3
                        </a>
                    </h4>
                </div>

                <div id="accordionThree" class="panel-collapse collapse">
                    <!-- panel body -->
                    <div class="panel-body">
                        You must take personal responsibility.
                        You cannot change the circumstances,
                        the seasons, or the wind, but you can change yourself.
                        That is something you have charge of.
                    </div>

                </div>

            </div>

        </div>

    <script type="text/javascript">
        $("[data-toggle=popover]").popover({
            html: true,
            content: function() {
                var clone = $('#popover-content').clone(true).html();
                return clone;
            }
        });
    </script>

</div>

<div style="border-top: solid 1px #aaaaaa; clear: both;" class="hidden-md hidden-lg"><br/><br/>
</div>
</div>

最佳答案

这是给你的demo

您可能需要更改一些css,但是您会明白的。

这是html的代码

<div class="container-fluid">
  <div class="row-fluid" style="margin-top:200px">
    <div class="span12" style="float: middle; margin: 15px 0px 15px 15px;">
   <a href="#" id="popoverExampleTwo">Popover Example 2</a>


      <div id="popoverExampleTwoHiddenContent" style="display: none">
         <div class="panel-group" id="accordion">
        <!-- accordion 1 -->
        <div class="panel panel-primary">
            <div class="panel-heading">
                <!-- panel-heading -->
                 <h4 class="panel-title">
                    <!-- title 1 -->
                    <a data-toggle="collapse" data-parent="#accordion" href="#accordionOne">
                        Collapsible Accordion 1
                    </a>
                </h4>

            </div>
            <!-- panel body -->
            <div id="accordionOne" class="panel-collapse collapse in">
                <div class="panel-body">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat</div>
            </div>
        </div>
        <div class="panel panel-success">
            <!-- accordion 2 -->
            <div class="panel-heading">
                 <h4 class="panel-title">
                    <!-- title 2 -->
                    <a data-toggle="collapse" data-parent="#accordion" href="#accordionTwo">
                        Collapsible Accordion 2
                    </a>
                </h4>

            </div>
            <!-- panel body -->
            <div id="accordionTwo" class="panel-collapse collapse">
                <div class="panel-body">Change does not roll in on the wheels of inevitability, but comes through continuous struggle. And so we must straighten our backs and work for our freedom. A man can't ride you unless your back is bent.</div>
            </div>
        </div>
        <div class="panel panel-warning">
            <!-- accordion 3 -->
            <div class="panel-heading">
                 <h4 class="panel-title">
                    <!-- title 3 -->
                    <a data-toggle="collapse" data-parent="#accordion" href="#accordionThree">
                        Collapsible Accordion 3
                    </a>
                </h4>

            </div>
            <div id="accordionThree" class="panel-collapse collapse">
                <!-- panel body -->
                <div class="panel-body">You must take personal responsibility. You cannot change the circumstances, the seasons, or the wind, but you can change yourself. That is something you have charge of.</div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        $("[data-toggle=popover]").popover({
            html: true,
            content: function() {
                var clone = $('#popover-content').clone(true).html();
                return clone;
            }
        });
    </script>
</div>

      </div>
      <div id="popoverExampleTwoHiddenTitle" style="display: none">
         Popover Example <b>2</b> - Title
      </div>

    </div>
  </div>
</div>


还有一点script可以在弹出式窗口正文中设置标题和内容

$(function(){

// Enabling Popover Example 1 - HTML (content and title from html tags of element)
$("[data-toggle=popover]").popover();

// Enabling Popover Example 2 - JS (hidden content and title capturing)
$("#popoverExampleTwo").popover({
    html : true,
    content: function() {
      return $('#popoverExampleTwoHiddenContent').html();
    },
    title: function() {
      return $('#popoverExampleTwoHiddenTitle').html();
    }
  });

});


我所做的只是通过javascript处理popover内容,我不太擅长解释,但您会了解此演示。

希望能回答这个问题

10-05 20:53