Fieldsets in Drupal are collapsible. Is there a simple way to re-cycle this开发者_高级运维 kind of functionality to a text field in a content type?
A text field is typically rendered as
<div class="field field-type-text field-field-my-field">
<div class="field-label"> My field Label: </div>
<div class="field-items">
....
</div>
</div>
Like with a field set, how would one make the field-label
clickable to collapse and expand the field-items
?
My current avenue of attack is to add the collapsed
css class with jQuery when the page is rendered, but am wondering if this kind of thing is already available somehow in the Drupal framework.
This was easier than I thought:
$(document).ready(function() {
$(".field-field-mytextfield .field-items").css('display','none');
$(".field-field-mytextfield .field-label").click ( function ()
{
$(this).parent().children( ".field-items").slideToggle('slow');
} );
});
精彩评论