On May 22, 11:53 am, Jay Tee <[EMAIL PROTECTED]> wrote:
> I have a grid with two <tbody> pairs. (I need to be able to hide
> either section of the table). I'm allowing the user to navigate
> between cells of the grid using their keyboard.
>
> When I key up (up arrow) or down (down arrow) within the same tbody,
> the cursor moves around like a charm. But when I get to the first row
> of the bottom tbody or the bottom row of the top tbody, the cursor
> moves no further.
>
> Here's a snippet: (for up arrow - it's similar to down arrow):
>
> this.up('tr').previous('tr').down('input[type="text"]').activate();
Previous works on siblings, since the rows are in different
tableSections, they aren't siblings.
Users can navigate using the tab key (zero script required), you can
control the order using the tabindex attribute.
If you must use script, you can use the rowIndex property (which is
relative to all the rows in the table) of the row you are in as the
basis for going to the upper or lower row.
e.g.
function upRow(tr)
{
var tableParent = tr.parentNode.parentNode;
return tableParent.rows[ tr.rowIndex - 1 ];
}
The above is just an example of the algorithm, you will need to check
that there is a row above (i.e. rowIndex > 0), that it isn't in the
thead, etc.
--
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 rubyonrails-spinoffs@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---