jquery - Rails: Bootstrap Collapse doesn't work after refresh -


i have simple bootstrap collapse (as seen working in this fiddle):

<h3>     <a data-toggle="collapse" href="#collapseexample" aria-expanded="false" aria-controls="collapseexample">         our name</a> </h3> <div class="collapse" id="collapseexample">     <p>         stuff our name.     <p> </div> <h3>     <a data-toggle="collapse" href="#collapsetwo" aria-expanded="false" aria-controls="collapsetwo">         bottom line basics</a> </h3> <div class="collapse" id="collapsetwo">     <p>     more words!     </p> </div> 

i trying put in "about us" page. works fine in jsfiddle, in rails app, see behavior:

load different page (not us), navigate "about us" page: collapse works fine.

refresh "about us" page: collapse doesn't work.

i figure has turbolinks, nothing i'm trying working.

it ended being interference on click event caused this "smooth scrolling" script.

i fixed matching against "collapse":

   $('a[href*=#]:not([href*=#collapse])').click(function() {       if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {         var target = $(this.hash);         target = target.length ? target : $('[name=' + this.hash.slice(1) +']');         if (target.length) {           $('html,body').animate({             scrolltop: target.offset().top           }, 1000);           return false;         }       }     }); 

Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -