That's true, and yes that CSS selector should include buttons.
If you're building your DOM dynamically, you may want to create a form
element factory. Then this can automatically add the focus observer each
time you create a form element.
var focused;
function onElementFocus(event)
{
focused = event.element();
}
function createFormElement(type, attributes)
{
return new Element(type, attributes).observe('focus', onElementFocus);
}
// create a form element
var button = createElement('button', {name: 'myButton'}).update('Click
me!');
$(document.body).insert(button);
-Hector
On Wed, Nov 19, 2008 at 8:07 PM, kangax <[EMAIL PROTECTED]> wrote:
>
> On Nov 19, 3:39 pm, "Hector Virgen" <[EMAIL PROTECTED]> wrote:
> > A prototype way might go something like this (untested):
> > var focused;
> >
> > Event.observe(document, 'dom:loaded', function()
> > {
> > $$('input, select, textarea').invoke('observe', 'focus',
> function(event)
> > {
> > focused = event.element();
> > });
> >
> > });
> >
>
> It just wouldn't work with dynamically added content : )
> Also, shouldn't `BUTTON` be there as well?
>
> > -Hector
>
> [...]
>
> --
> kangax
> >
>
--~--~---------~--~----~------------~-------~--~----~
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 [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-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---