Is there a way to use Prototype.js to check whether an element exists
before I try to do something to it?
I sometimes find myself doing Element.remove(''foo'') and if the
element
doesnt exist, I get a javascript error. Expected behavior for this
example would be for the function to silently return since the element
has already been removed.
Something like Element.exists(''foo'') would be helpful.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
What about if ($(''foo'')) { } ?
On 7/23/07, JakeO <offsky-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:>
> Is there a way to use Prototype.js to check whether an element exists
> before I try to do something to it?
>
> I sometimes find myself doing Element.remove(''foo'') and
if the element
> doesnt exist, I get a javascript error. Expected behavior for this
> example would be for the function to silently return since the element
> has already been removed.
>
> Something like Element.exists(''foo'') would be helpful.
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
if($(''foo'')){ ... }
best,
thomas
Am 23.07.2007 um 21:22 schrieb JakeO:
>
> Is there a way to use Prototype.js to check whether an element exists
> before I try to do something to it?
>
> I sometimes find myself doing Element.remove(''foo'') and
if the element
> doesnt exist, I get a javascript error. Expected behavior for this
> example would be for the function to silently return since the element
> has already been removed.
>
> Something like Element.exists(''foo'') would be helpful.
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
var element = $(''id'');
if (element) element.remove()
Should get you to where you want.
Regards,
Tobie
JakeO wrote:> Is there a way to use Prototype.js to check whether an element exists
> before I try to do something to it?
>
> I sometimes find myself doing Element.remove(''foo'') and
if the element
> doesnt exist, I get a javascript error. Expected behavior for this
> example would be for the function to silently return since the element
> has already been removed.
>
> Something like Element.exists(''foo'') would be helpful.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---