Single row selecting in doesn't work.

Single row selecting in doesn't work.

AransajaAransaja Posts: 8Questions: 4Answers: 0
edited June 2014 in Free community support

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 );
    } );
} );
This discussion has been closed.