Quantcast
Channel: Free community support — DataTables forums
Viewing all articles
Browse latest Browse all 35278

Single row selecting in doesn't work.

$
0
0

I am able to select multiple rows with the code below

        $('#LineTables tbody').on('click', 'tr', function () {
           
            if ($(this).hasClass('selected')) {
                $(this).removeClass('selected');
                
            }
            else {
                $(this).addClass('selected');
                
            }
        });

But everytime I'm trying to use this code below I always get this Error. TypeError: $(...).DataTable is not a function. I put the js and css files correctly into my project. What causes this problem.

$(document).ready(function() {
    var table = $('#example').DataTable();
 
    $('#example tbody').on( 'click', 'tr', function () {
        if ( $(this).hasClass('selected') ) {
            $(this).removeClass('selected');
        }
        else {
            table.$('tr.selected').removeClass('selected');
            $(this).addClass('selected');
        }
    } );
 
    $('#button').click( function () {
        table.row('.selected').remove().draw( false );
    } );
} );

Viewing all articles
Browse latest Browse all 35278

Trending Articles