mongolito404
Mon, 02/20/2012 - 08:17
Permalink
Using Drupal behaviors and jQuery once, the code would be
(function($) { Drupal.behaviors.customToggler = { attach: function(context, settings){ $(".toggler", context).once('custom-toggler').click(function(){ $(this).next().slideToggle("slow"); return false; }).next().hide(); }; }; })(jQuery);
This allows the script to work for elements added after the page loads.
More information about text formats
Drupal Behaviors
Using Drupal behaviors and jQuery once, the code would be
(function($) { Drupal.behaviors.customToggler = { attach: function(context, settings){ $(".toggler", context).once('custom-toggler').click(function(){ $(this).next().slideToggle("slow"); return false; }).next().hide(); }; }; })(jQuery);This allows the script to work for elements added after the page loads.