Created
November 26, 2010 21:07
-
-
Save gavinblair/717214 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('fieldset.collapsible:not(.tao-processed) > legend > .fieldset-title').each(function() { | |
var fieldset = $(this).parents('fieldset').eq(0); | |
fieldset.addClass('tao-processed'); | |
// Expand any fieldsets containing errors. | |
if ($('input.error, textarea.error, select.error', fieldset).size() > 0) { | |
$(fieldset).removeClass('collapsed'); | |
} | |
// Add a click handler for toggling fieldset state. | |
$(this).click(function() { | |
if (fieldset.is('.collapsed')) { | |
$(fieldset).removeClass('collapsed').children('.fieldset-content').show(); | |
} | |
else { | |
$(fieldset).addClass('collapsed').children('.fieldset-content').hide(); | |
} | |
return false; | |
}); | |
}); |
This is actually copied from Drupal's collapsible fieldset functionality. It has to be run again on dynamically added fieldsets.
$('fieldset.collapsible').bind('click', function(){
$(this).toggleClass('collapsed'); // where collapsed is display:none or height = 10px, overflow: hidden (or whatever hides the fieldset)
})
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What the what now?
also, you can switch this
$(this).click(function() { if else }
with$(this).toggle(function() { }, function(){} )
which is way awesomer (because you can have as many as you want...)