Martin Bialasinski wrote:
> On 1/23/07, Christophe Porteneuve <[EMAIL PROTECTED]> wrote:
>
> > On the other hand, I believe it would make a lot of sense to have
> > findFirstElement rely on tabindex attributes when they exist, which
> > would provide spec consistency and maximum flexibility for page developers.
If you mean consistency with the HTML spec in regard to navigation of
elements within forms, that will likely require that the
form.getElements method is re-written to return elements in the right
order.
>
> This is an excellent idea.
Maybe, but difficult to implement in Prototype.
The findFirstElement method is unreliable because it is dependent on
the results of form.getElements(), which, as pointed out in another
thread, does not return results in the order they are coded in the
document unless the elements in the form are organised (probably by
chance) in the same order as that used in Form.Element.Serializers.
One solution is to use the form's elements collection, but since that
is unreliable in IE with dynamic forms, it may be better to walk down
the DOM tree to find the elements in the correct order.
It also seems reasonable that if you are going to go to the length of
getting all the tabindexes and finding the lowest one, as well as
keeping all the elements in the right order, that you will also check
if the elements are visible by looking at their (possibly inherited)
CSS visibility and display property values, and finally ignoring those
that are readonly.
And should elements that can't be successful (e.g. those with no name
attribute) be ignored?
All that seems an amazing amount of work, and will likely still not
identify the "right" element in some cases. The element in the page
that should get focus (if it needs to be set programatically) must be
known at the time the page is generated or updated. In that case, it
is much simpler to use something like:
$('elementID').focus();
or
$('form').elements[0].focus();
--
Rob
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---