<tr>
<td class = "edit edit_c1">C1</td>
<td>C2</td>
<td class = "edit edit_c3">C3</td>
<td>C4</td>
<tr>
<tr>
<td class = "edit edit_c1">C1</td>
<td>C2</td>
<td class = "edit edit_c3">C3</td>
<td>C4</td>
<tr>
I have some Jeditable code that runs on “.edit_c1, edit_c2 etc”. I want to traverse to the next editable column on TAB. I have another class “edit” to identify editable columns. I am assuming nextall() should work but none of the options below gets me the handle to the next editable column (TD with class = “edit”).
$(".edit").keypress(function (event) {
var td = $(this).closest('td');
console.log(this);
// returns <td class="edit edit-c1" style="white-space:nowrap">
switch (event.keyCode) {
// TAB
case 9:
console.log("TABBED");
console.log($(this).closest('td').next('td[@class=edit]'));
//Above logs [td] a handle to C2 instead of C3
console.log($(this).closest('td').nextAll(':has(.edit):first').find('.edit'));
//Above logs []
console.log($(this).nextAll(':has(.edit):first').find('.edit'));
//Above logs []
console.log($(this).closest('td').next().find('.edit'));
//Above logs []
break;
}
});
The code does work to a point where I see the console.log messages in firebug. Jeditable portion of the code below.
$('.edit-c1').editable(function (value, settings) {
var tr = $(this).closest('tr'),
id = tr[0].id;
//comment the line below if you want to test
//saveWSField(id, value, "C1");
return (value);
}, {
type: 'text',
onblur: 'submit'
});
I haven’t looked in too much detail at what jeditable injects into the DOM to make things editable, but it seems to inject a small form.
With this in mind, the following works for me:
html
Then the following javascript: