Navigate through table rows using the keyboard

Version 0.5.7. Licensed under the MIT-License.

Feature demo: Use checkboxes as activation elements

This page demonstrates to use checkboxes as activation elements. If a checkbox is activated it's checked value is inverted (unchecked boxes will be checked, checked boxes will be cleared).

To make this work only two options to the tableNavigation call have to be changed.

jQuery.tableNavigation({
	activation_selector: 'input[@type=checkbox]',
	on_activate: function(row){
		var checkbox = $('input[@type=checkbox]', row).get(0);
		checkbox.checked = !checkbox.checked;
		return false;
	}
});

First of the activation_selector option says that the first checkbox (input elements with a type attribute of checkbox) in a row should be focused if a row is selected. This is important for the arrow keys to work (they need an focused element in a row).

The second step is to tell the script that it should not follow a link if a row is activated. For this we define a function for the on_activate option. This function is executed by the script each time a row is activated an passes this row as the first parameter. There we now get the first checkbox in the activated row ($('input[@type=checkbox]', row).get(0);) and invert it's checked attribute. This will check unchecked boxes and clears checked ones. At last we return false to prevent the script from doing it's default stuff (following a link).

That's it. Much fun.

Requested by Hakan Axelsson, implemented by Stephan Soller in v0.5.7.

The MIT License

Copyright (c) 2006 Stephan Soller <stephan.soller@addcom.de>, Florian Seefried <florian.seefried@helionweb.de>.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.