Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data-toggle collapse broken on href for alpha 3 #20396

Closed
joncoop opened this issue Jul 28, 2016 · 2 comments
Closed

data-toggle collapse broken on href for alpha 3 #20396

joncoop opened this issue Jul 28, 2016 · 2 comments
Labels

Comments

@joncoop
Copy link

joncoop commented Jul 28, 2016

The button with data-target still works, but the a href does not. It worked in alpha 2. Also, it does work on doc page, just not on my test site. Are docs/examples all using latest build?

If I use a button to open collapsed item, then href will correctly scroll to target. However, href scrolls to top of page if item is in collapsed state when link is clicked.

Copied code directly from here: http://v4-alpha.getbootstrap.com/components/collapse/#example

@judetucker
Copy link

I am unable to confirm this as an issue. It works as intended both locally for me as well as here: http://codepen.io/anon/pen/akjEpO

I would say check your code to see if you have an extra href="#" in there somewhere that may be making your page push to the top.

@joncoop
Copy link
Author

joncoop commented Aug 7, 2016

I found the problem. It was on my end. There is a conflict with some smooth scroll JS that I also had. As soon as I disable smooth scroll, everything worked fine. Here's the problematic code:

/* Smooth scroll to selected anchor
 * https://css-tricks.com/snippets/jquery/smooth-scrolling/
 */
$(function() {
  $('a[href*="#"]:not([href="#"])').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;
      }
    }
  });
});

@joncoop joncoop closed this as completed Aug 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants