Having two bootstrap links causes accordion to not work properly

116 Views Asked by At

I have included two bootstrap links in my HTML page. This is causing issues with the accoridan I have included. The accordian once opened wont collapse when clicked again.

I have figured out that this is because of the two bootstrap links and the problem is solved when I remove one. Does anyone know why this is occurring and how to solve this?

The two bootstrap links are a local copy and a CDN copy. I use the CDN primarily and have a local backup incase the CDN is down.

Any help is appreciated.

1

There are 1 best solutions below

0
Shekhar Chikara On

Unfortunately, Bootstrap doesn't provide a specific variable for the fallback purpose. However, you can still achieve the CDN fallback behavior, you can test for one of the bootstrap plugins. For example, you can check for the modal plugin like below-

<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script>$.fn.modal || document.write('<script src="/js/bootstrap.min.js"><\x3C/script>')</script>

This will only load the local version of the bootstrap.min.js file if the CDN doesn't work.

Please note that this might fail in future if the modal plugin gets renamed or removed in future.