Bootstrap Accordion does not work when loading content with ajax

-1

I have my accordion, inside the body of it, I have a div where the content is loaded via ajax

<div class="panel-group" id="accordion">
  <div class="panel panel-default">
    <div class="panel-heading">
      <h4 class="panel-title">
        <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
          Titulo
        </a>
      </h4>
    </div>
    <div id="collapseOne" class="panel-collapse collapse in">
      <div class="panel-body">
        <div class="conteudo" data-url="MINHA URL PARTIAL">
Carregando
</div>
      </div>
    </div>
  </div>
    <div class="panel-heading">
      <h4 class="panel-title">
        <a data-toggle="collapse" data-parent="#accordion" href="#collapseThree">
          Titulo 2
        </a>
      </h4>
    </div>
    <div id="collapseThree" class="panel-collapse collapse">
      <div class="panel-body">
            <div class="conteudo" data-url="MINHA URL PARTIAL">Carregando</div>
      </div>
    </div>
  </div>
</div>

and for this I use the following javascript code:

    $(".conteudo").each(function (index, item) {
        var url = $(item).data("url");
        if (url && url.length > 0) {
            $(item).load(url);
        }
    });

But while it loads these views, which sometimes can take time, the accordion simply hangs and does not appear the hover of the link, clicking on the accordion tabs it does nothing

Something wrong?

    
asked by anonymous 27.09.2014 / 00:13

2 answers

0

In searches, I saw that it's because of the collapse.js lib that the bootstrap uses. It does not get support for this.

One way to solve this is to click on the accordion.

    
03.10.2014 / 14:25
0

Hi,

Your HTML is invalid. Before your second <div class="panel-heading"> is missing a <div class="panel panel-default"> .

Here has an example working.

    
27.09.2014 / 01:04