Alex Weber
Mon, 02/20/2012 - 09:38
Permalink
It would look something like this:
(function($) { Drupal.behaviors.my_node_toggle = { attach: function(context, settings) { $(".toggler", context).click(function(){ $(this).next().slideToggle("slow"); return false; }).next().hide(); }); } }; })(jQuery);
That said, I believe your javascript could be put in an external file and added using a preprocess funciton to keep the template free of non-markup! :) Sorry, don't mean to be annoying or a stickler! :)
More information about text formats
Using behaviors in your example
It would look something like this:
(function($) { Drupal.behaviors.my_node_toggle = { attach: function(context, settings) { $(".toggler", context).click(function(){ $(this).next().slideToggle("slow"); return false; }).next().hide(); }); } }; })(jQuery);That said, I believe your javascript could be put in an external file and added using a preprocess funciton to keep the template free of non-markup! :) Sorry, don't mean to be annoying or a stickler! :)