dobby wrote:
> Hi,
>
> The show, hide, toggle methods are great on the element object but it
> would also be nice to have a setVisisble(boolean) method. This allows
> you to set the visibility of an element depending on a Boolean
> expression. With the current api you have to if else this behavior.
>
> Example:
>
> $("myelement").setVisible(element.checked);
>
> With the current api you would have to do something like this:
>
> if(element.checked){
> $("myelement").show();
> }else {
> $("myelement").hide();
> }
>
FWIW, here are two other possibilities:
// ternary statement
$("myelement")[element.checked ? 'show' : 'hide']();
// custom Element method
Element.addMethods({
setVisible: function(element, visible) {
element = $(element);
return element[visible ? 'show' : 'hide']();
}
});
$("myelement").setVisible(element.checked);
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---