Whay can I not disable keys on click evet?

Whay can I not disable keys on click evet?

OnLogOnLog Posts: 18Questions: 6Answers: 1

I'm not able to disable keys when click on button.
If I use it outside the click event the keytable is disabled....

See this test case: https://jsfiddle.net/supernova404/jg60we4o/209/

I want to disable keys when a surten button is clicked: .buttons-page-length

var table = $('#dynamicTableDetailChild').DataTable({
             keys: true
});
$('.buttons-page-length').on('click', function(){
          console.log('inside');
          $('#dynamicTableDetailChild').DataTable().keys.disable();
          //table.keys.disable();
});

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,545Questions: 26Answers: 4,988

    When I click the pageLength button the keyTable extension is disabled. Maybe I'm not understanding the problem description. Please provide the exact steps to replicate the issue.

    Kevin

  • kthorngrenkthorngren Posts: 21,545Questions: 26Answers: 4,988

    I updated the test case to show the Keys enabled state in the click event.
    https://jsfiddle.net/7bL8t4u2/

    Kevin

  • OnLogOnLog Posts: 18Questions: 6Answers: 1

    I was expecting the blue border to disapear when it got disabled? The problem is that I can still copy from this cell. So when I for exaple open an editor window I still copy from the main table because the blue border is still active. I guess I have missunderstood something!?

  • kthorngrenkthorngren Posts: 21,545Questions: 26Answers: 4,988
    Answer ✓

    Use cell.blur() to blur the focus from the table before keys.disable(). Updated test case:
    https://jsfiddle.net/6oebd7yk/

    Kevin

  • OnLogOnLog Posts: 18Questions: 6Answers: 1

    This is just perfect. Thanks alot!

Sign In or Register to comment.