bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

Accordion: Restrict expanding to button click in heading

Open smaye81 opened this issue 11 years ago • 6 comments

I have an <accordion-heading> tag in my accordion with a couple controls inside (inputs, buttons, etc.), but I only want the accordion to expand when one specific button is clicked. Nothing else should trigger the expand/collapse. It doesn't seem there is a way to do this.

I've tried:

  1. Setting is-open to false and setting it to true in the ng-click of my button. Doesn't work because clicking anywhere inside the accordion-heading toggles this boolean.
  2. Setting is-disabled to true and then setting it to false when the button is clicked. Also doesn't work, the accordion stays disabled
  3. Wrapping ONLY my button with the <accordion-heading> tag. This causes the rest of the markup in my heading to part of the 'expand/collapse' detail.

smaye81 avatar Feb 20 '15 18:02 smaye81

https://github.com/angular-ui/bootstrap#support

karianna avatar Feb 20 '15 18:02 karianna

What is the resolution? I did not see any further information in the link: https://github.com/angular-ui/bootstrap#support

pedro-meza avatar May 06 '15 14:05 pedro-meza

I figured it out....

set the is-disabled to true for the accordion-group, such as:

<accordion-group  is-disabled="true" is-open="status-open">

Then create an accordion-heading and add an ng-click to a specific text or element, such as:

<accordion-heading>
 Accordion Heading <button class="btn btn-primary" ng-click="open()">Open</button>
</accordion-heading>

pedro-meza avatar May 06 '15 14:05 pedro-meza

@pedro-meza The solution works like a charm:):):) How does is-disabled in accordion-group relate to ng-click in accordion-heading?

Thank you

aswini-19aug avatar Dec 18 '15 07:12 aswini-19aug

@aswini-19aug The status-open is just a scope variable that is set to true or false in the open() function.

Mungoid avatar Dec 21 '15 23:12 Mungoid

@pedro-meza it works fine, thanks for snippet

vcollado avatar Aug 09 '17 07:08 vcollado