Use input fields inside table with key navigation

Use input fields inside table with key navigation

fg.samuelfg.samuel Posts: 1Questions: 1Answers: 0

I have a table with input fields in cell.
Its configured with keytable navigation.
I want to when user navigate to that cell, the input field get focus and select all text to replace

This way, user can use only keyboard and edit input fields.

How would I do that?

Example: http://jsfiddle.net/5p7gtwrc/

Answers

  • bindridbindrid Posts: 730Questions: 0Answers: 119
    $('#id_table').DataTable( {
            keys: true
        } ).on("focus", "input", function(){$(this).select();})
    

    http://jsfiddle.net/5p7gtwrc/4/

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    oops doesn't work when tabbing

  • bindridbindrid Posts: 730Questions: 0Answers: 119
    $('#id_table').DataTable( {
            keys: true
        } ).on( 'key-focus', function ( e, datatable, cell, originalEvent ) {
         
            $('input', cell.node()).focus();
    
        } ).on("focus", "td input", function(){
            $(this).select();
        })
    
    
    
  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    This is @bindrid 's last code in a fiddle: http://jsfiddle.net/5p7gtwrc/22/ . works a treat!

This discussion has been closed.