I can't auto focus the first cell (by focus: ':eq(0)' )

I can't auto focus the first cell (by focus: ':eq(0)' )

PryanichkinPryanichkin Posts: 2Questions: 1Answers: 0

Link to test case: https://obmen1.pbteamstudio.com/opers.html

I can't auto focus the first cell (by focus: ':eq(0)' )

let table = $(TABLE_ID).DataTable({
...
keys: {
   editor: editor,
   focus: ':eq(0)',
   blurable: false,
},
...
});

Please indicate what I am doing wrong!

This question has an accepted answers - jump to answer

Answers

  • PryanichkinPryanichkin Posts: 2Questions: 1Answers: 0

    Working solution is:

    let table = $(TABLE_ID).DataTable({
    ...
    initComplete: function () {
       table.cell(':eq(0)').focus();
    }
    ...
    });
    

    But, why keys.focus: ':eq(0)' didn't work?

  • kthorngrenkthorngren Posts: 20,425Questions: 26Answers: 4,794
    Answer ✓

    My guess is KeyTable tries the focus: ':eq(0)', option before the table is loaded from Ajax and the td is not in the DOM yet.

    Kevin

Sign In or Register to comment.