Datatables with nav-tabs broken onClick

Datatables with nav-tabs broken onClick

jwestjwest Posts: 8Questions: 4Answers: 0
edited September 2019 in Free community support

I am using datatables and nav-tabs in a form. I am having a weird problem.

If the form size has size greater than 992 pixels, when click in a row of the table, the click works and

the row is selected. Otherwise, the datatables row is not selected.

Here is a fiddle with the problem. https://jsfiddle.net/ontxswgr/1/

//JS
var tableTest;
    $(document).ready(function () {
      tableTest = $('#example').DataTable();
    });
    $('#example').on('click', 'tr', function () {
      if ($(this).hasClass('selected')) {
        $(this).removeClass('selected');
      } else {
        tableTest.$('tr.selected').removeClass('selected');
        $(this).addClass('selected');
      }
    });

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • allanallan Posts: 64,032Questions: 1Answers: 10,555 Site admin

    You've got a ul.nav.nav-tabs element over the table which is capturing the click events. To confirm and see this yourself, right click and select "Inspect" when the output is small enough to see this issue.

    Allan

This discussion has been closed.