Skip to content

Instantly share code, notes, and snippets.

@szeidler
Created November 18, 2014 14:40
Show Gist options
  • Save szeidler/e5efb30d5b65f08b093e to your computer and use it in GitHub Desktop.
Save szeidler/e5efb30d5b65f08b093e 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