Event.element returns an element.  Alert-ing it performs an implicit  
toString().

There are two versions of match()--the one it seems you're trying to  
use is a String method, which takes a regex as an argument. The other  
you correctly identified as a Prototype extension of Element. [1].   
Using this version of match() accepts a CSS selector as a string, and  
returns a boolean.

Event.element(evt).match('form#someFormId input.someClass'); //  
returns boolean..

You could also do (less recommended)
Event.element(evt).innerHTML.match(regex);
Event.element(evt).inspect().match(regex);  // [2]

What you don't say explicitly, but what I infer, is that you're  
trying to get the value of some form element.
var val = Event.element(evt).value;
var val = $F(Event.element(evt)); // [3]


TAG

1. http://prototypejs.org/api/element/match
2. http://prototypejs.org/api/element/inspect
3. http://prototypejs.org/api/utility/dollar-f
3b. http://prototypejs.org/api/form/element/getValue

On Aug 2, 2007, at 3:22 PM, Gilant wrote:

>
> A have an observer watch for a click on a link. Inside the triggered
> function, I want to extract a piece of information from the URL.
> Currently I am able to do:
> alert(Event.element(el));
>
> This displays the url string of the link, which is exactly what I need
> to work with. However, when I try:
> Event.element(el).match(//);
>
> I get a javascript error "selector.match is not a function". I also
> note that prototype has an extension to Element named match as well.
> Am I accidentally using prototypes when I want the native javascript
> function? Or does Event.element() return a string to alert but
> something else otherwise? Is there any way to get the string displayed
> in the alert into a form I _can_ use .match(//) on?
>
> Confused again,
> Sean
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to