简体   繁体   English

Bootstrap手风琴:展开/折叠全部不起作用

[英]Bootstrap accordion: Expand / Collapse all not working

I found that solution, to expand all accordion sections: http://www.bootply.com/peFUdnwOpZ 我找到了扩展所有手风琴部分的解决方案: http : //www.bootply.com/peFUdnwOpZ

I copied the code in Joomla. 我在Joomla中复制了代码。 Via Gantry I loaded Javascript file. 通过龙门,我加载了Javascript文件。 I tried even, to load the javascript within the article. 我什至尝试加载文章中的javascript。

But It is not working. 但这是行不通的。 Can Anybody help? 有人可以帮忙吗?

Background information: I had to add bootstrap min.js , otherwise, the function "accordion" was not working properly. 背景信息:我必须添加bootstrap min.js ,否则,“手风琴”功能无法正常工作。 Template is working with Bootstrap 3.3.6. 模板正在使用Bootstrap 3.3.6。

I tried even to add the exact same files, loaded in http://www.bootply.com/peFUdnwOpZ . 我什至尝试添加完全相同的文件,这些文件已加载到http://www.bootply.com/peFUdnwOpZ中

  1. //ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
  2. //netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js
  3. //netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css

Next Try. 下次尝试。 I loaded script via Joomla plugin. 我通过Joomla插件加载了脚本。 I loaded the script in header and body, before and after head/body tag. 我将脚本加载到head / body标签之前和之后的标头和正文中。

Nothing worked. 没事。

I traced it down: On another template, I worked with, I figured out, that the order of loading the 3 javascripts is very important. 我找到了答案:在另一个模板上,我发现,加载3个javascript的顺序非常重要。 So, loading manually before end of header is much important! 因此,在标头末尾之前手动加载非常重要! first jquery.min.js than bootstrap.min.js and than custom javascript (see in the example link) worked. 首先是bootstrap.min.js和自定义javascript(请参见示例链接)中的jquery.min.js。 But on my own site, it seems, there are some errors in loading jquery and bootstrap javascript properly. 但是在我自己的网站上,正确加载jquery和bootstrap javascript时似乎出现一些错误。 Because console says: 因为控制台说:

null is not an object (evaluating '$('.closeall').click') null不是对象(评估'$('。closeall')。click')

So, it misses the link to the other javascript files. 因此,它会丢失指向其他javascript文件的链接。 Maybe some can help? 也许有些可以帮助?

I believe you may have forgot to add the following piece of code in your custom js file - 我相信您可能已经忘记在自定义js文件中添加以下代码了-

$('.closeall').click(function(){
    $('.panel-collapse.in')
    .collapse('hide');
});
$('.openall').click(function(){
    $('.panel-collapse:not(".in")')
    .collapse('show');
});

Hope this may work for you :-) 希望这对您有用:-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM