Hi,

Rather than

> var element = event.element();

...try just using `this`, since `this` is guaranteed to be the element
that you assigned the handler to (the form) rather than a subordinate
element (which it may be because of event bubbling). Now, I would
expect `event.element()` on a `submit` event to return the form, but
there's no need for it in this case, just use `this`.

BTW, you can change this:

* * * *
$$('form').each
(
  function(object)
  {
    Event.observe(object, "submit", preventDoubleClick);
  }
);
* * * *

to this:

* * * *
$$('form').invoke('observe', 'submit', preventDoubleClick);
* * * *

...and thereby avoid creating a bunch of unnecessary functions (not
that they were likely doing much harm).

HTH,
--
T.J. Crowder
Independent Software Engineer
tj / crowder software / com
www / crowder software / com

On Mar 15, 10:58 am, Vecchia Spugna <vecchiaspu...@gmail.com> wrote:
> Hello everyone!
>
> i would like to do script in this way:
>
> Event.observe(window, "load", function()
> {
>   $$('form').each
>   (
>     function(object)
>     {
>       Event.observe(object, "submit", preventDoubleClick);
>     }
>   );
>
> });
>
> function PreventDoubleClick(event)
> {
>   var element = event.element();
>   submit_button = element.down("input[type='submit']");  // <---- This
> doesn't work! $(this).down("input[type='submit']" doesn't work!
>   .....//disable button and reenable it later..
>
> }
>
> So, what i don't understand is why the parameter looses its conception
> of DOM under it. I can obtain the CORRECT result doing $
> ('myform').down("input[type='submit']")
>
> what is the concept i am ignoring??
>
> thank you very much

-- 
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 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to