I have a table that represents a physical 12x8 grid. Each <td> contains the text name (A1-H12) of the grid co-ordinate. I've added the jquery-ui selectable interaction to the table. I want users to be able to select an arbitrary set of grid co-ordinates. As well as selecting by <td>, I'd like the user to be able to select entire rows and/or columns by clicking on the row or column <th>. Selection by <th> is causing me some difficulty:
<td>s are in the same column (or row) as the selected <th>?<th> to the correct set of <td>s? stop, selected or selecting?
If someone had a good code example of real-world selectable use, I'd really appreciate the link.
My jquery (which only allows me to look at the selected objects since I'm very unsure of how to do things):
$(function(){
$('#selectable').selectable({
filter:'td,th',
selected: function(event, ui){
console.log(event);
console.log(ui);
var s=$(this).find('.ui-selected');
console.log(s);
}
})
});
The table looks like this:
<table id='selectable'><tr><th> </th><!-- empty cell over row labels--><th class='colhead'>1</th>...<th class='colhead'>12</th></tr><tr><th class='rowhead'>A</th><td>A1</td>...<td>A12</td></tr>...<tr><th class='rowhead'>H</th><td>H1</td>...<td>H12</td></tr></table>