Skip to content

Instantly share code, notes, and snippets.

@thelebster
Forked from szeidler/drupal-ajax-accordion.js
Created October 22, 2016 05:45
Show Gist options
  • Select an option

  • Save thelebster/563dc99f4bcf15f979f4b6802f3d1bff to your computer and use it in GitHub Desktop.

Select an option

Save thelebster/563dc99f4bcf15f979f4b6802f3d1bff to your computer and use it in GitHub Desktop.
Use custom jQuery toggle functionality in Drupal 7 to prevent multiple triggered elements, because of updated DOM
(function ($) {
Drupal.behaviors.accordion = {
attach: function (context, settings) {
$('.accordion h3.title').once('accordion', function () {
$('.accordion h3.title').toggle(function () {
// Actions here
}, function () {
// Actions here
});
});
}
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment