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

Collapse plugin does not correctly set the "collapsed" class on accordion heading links #7213

Closed
dynamicdan opened this issue Mar 8, 2013 · 4 comments
Labels

Comments

@dynamicdan
Copy link

This line:

$this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed')

Only works to remove or add the collapsed class on the element clicked. It does not updated the element that was previously expanded/clicked. So the class usage becomes inconsistent quickly and stops me easily styling stuff.

Note diff b/w accordion-heading and accordion-body.

@btholt
Copy link

btholt commented Mar 8, 2013

I also just ran into this very same issue.

btholt pushed a commit to btholt/bootstrap that referenced this issue Mar 11, 2013
sody added a commit to sody/bootstrap that referenced this issue Mar 29, 2013
@alterphp
Copy link

Don't know if it helps but I fixed it by adding this in a .ready function :

    $('.collapse').on('hide', function () {
        $('[href="#'+$(this).attr('id')+'"]').addClass('collapsed');
    });

It's pretty surely not "abstract" enough to be rawly implemented in Bootstrap...

@fat
Copy link
Member

fat commented Jun 28, 2013

pls reopen with jsfiddle if not fixed in 3.0

@fat fat closed this as completed Jun 28, 2013
fat added a commit that referenced this issue Jun 28, 2013
Fixes #7213 Collapse plugin does not correctly set the "collapsed" class.
@icem
Copy link

icem commented Dec 3, 2014

For anybody who wants workaround for bootstrap 2:

$(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) {
  var $this = $(this);
  var parent = $this.attr('data-parent');
  var $parent = parent && $(parent);
  if ($parent) $parent.find('[data-toggle=collapse][data-parent=' + parent + ']').not($this).addClass('collapsed');
});

@twbs twbs locked and limited conversation to collaborators Dec 3, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants