Created
July 11, 2010 11:39
-
-
Save rctay/471483 to your computer and use it in GitHub Desktop.
[django] uncollapse all collapsible fieldsets
This file contains 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
/** | |
* Provides the function 'uncollapse_all' that expands/uncollapses all | |
* unexpanded/uncollapsed fieldsets. | |
* | |
* Known to work with django 1.2<=, <=1.3.0a0. | |
*/ | |
django.jQuery(document).ready(function($) { | |
var e = $("fieldset.collapse a.collapse-toggle"); | |
// obtain the jquery click handler that toggles the groups; we assume | |
// that the first handler is that | |
var fn = $.data(e[0]).events['click'][0].handler; | |
// if odd, the group is shown - trigger the handler to hide it. | |
var filter = function() { | |
return ($.data(this, "lastToggle"+fn.guid) || 0) % 2; | |
}; | |
var handler = function() { $(this).trigger('click'); } | |
uncollapse_all = function() { | |
e.filter(filter).each(handler); | |
return false; | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment