Changed method of detecting disabled per
https://github.com/zurb/foundation-sites/pull/9812#discussion_r109806300
Altered docs to reflect current functionality of disable accordions,
documented below.
If an accordion is disabled, all motion methods (`up`, `down`, `toggle`)
get eaten, with the exception of `down` when combined with `firstTime`.
Added a `console.info()` message to indicate when these methods are
attempted on a disabled accordion.
### Disabled
-There may be times where you want to disable pane switching on an accordion. This can be accomplished by setting the disabled attribute.
+There may be times where you want to disable pane switching on an accordion. This can be accomplished by setting the `disabled` option.
+
+<div class="warning callout">
+ <p>The `disabled` option disables all up, down, and toggle methods of an accordion. If you wish to manipulate a disabled accordion with <a href='#javascript-reference'>JavaScript</a>, you will need to remove the `disabled` option from the accordion.</p>
+</div>
```html_example
<ul class="accordion" data-accordion disabled>
<li class="accordion-item is-active" data-accordion-item>
<a href="#" class="accordion-title">Accordion 1</a>
- <div class="accordion-content" data-tab-content >
+ <div class="accordion-content" data-tab-content>
Panel 1. I'm open because I'm loaded that way, but you can't close me
</div>
</li>
* @function
*/
toggle($target) {
- if ($target.closest('.accordion').is('[disabled]')) {
+ if ($target.closest('[data-accordion]').is('[disabled]')) {
+ console.info('Cannot toggle an accordion that is disabled.');
return;
}
if($target.parent().hasClass('is-active')) {
* checking firstTime allows for initial render of the accordion
* to render preset is-active panes.
*/
- if ($target.closest('.accordion').is('[disabled]') && !firstTime) {
+ if ($target.closest('[data-accordion]').is('[disabled]') && !firstTime) {
+ console.info('Cannot call down on an accordion that is disabled.');
return;
}
$target
* @function
*/
up($target) {
- if ($target.closest('.accordion').is('[disabled]')) {
+ if ($target.closest('[data-accordion]').is('[disabled]')) {
+ console.info('Cannot call up on an accordion that is disabled.');
return;
}