if($('pleaseWait')) $('pleaseWait').hide();

This is a classic coding issue. I disagree with you - in PHP I have
strict warnings on all the time so I'm always testing whether a
variable is set before accessing it. It's just a much safer way to
write code.

On Oct 16, 11:34 am, Eric <[EMAIL PROTECTED]> wrote:
> Hi,
> I am slowly introducing prototype in a "plain JS" application, and I
> was looking for a way to replace the following piece of code:
> var pleaseWait = document.getElementById('pleaseWait');
> if(pleaseWait)
> {
>   pleaseWait.style.display='none';
> }
> No rocket science here: if the processing was long enough to trigger
> the "please wait" screen (which is a "P" tag here), it is hidden.
> I did notice that this would NOT be the same than:
> $('pleaseWait').hide();
> ...since the later would fail if for some reason the DOM object has
> not been created.
> However, I was expecting that:
> Element.hide('pleaseWait');
> ... would be safe... but it isn't :o(
> Is there a clean prototypish way to do this?
> Wouldn't it be more convenient if the syntactic-sugar-free version of
> Element's methods were "null-proof safe"
> Eric
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 

Reply via email to