jquery - Row selecting in MVC doesn't work -


i make row getting selected through coding seems allow me selecting multiple rows.

1:   $('#linetables tbody').on('click', 'tr', function () { 2:          console.log("row clicked"); 3:          if ($(this).hasclass('selected')) { 4:              $(this).removeclass('selected'); 5:              console.log("removed selected class"); 6:          } 7:          else { 8:              $(this).addclass('selected'); 9:              console.log("added selected class"); 10:         } 11:     }); 

i want allow single row selection. source code datatables.net code below. error in console tells me typeerror: $(...).datatable not function. put js , css files given on website in project correctly. why still getting error message console. datatables.net confirms code

initialising datatables

that's it! we've got html table want enhance, , we've got >software , styles need. required to tell datatables >actually work magic on table. done few lines of javascript:

   $(document).ready( function () {        $('#table_id').datatable();    } )} 

source code datatables.net

1:   $(document).ready(function() { 2:   var table = $('#example').datatable(); 3:  4:   $('#example tbody').on( 'click', 'tr', function () { 5:       if ( $(this).hasclass('selected') ) { 6:           $(this).removeclass('selected'); 7:       } 8:       else { 9:           table.$('tr.selected').removeclass('selected'); 10:          $(this).addclass('selected'); 11:       } 12:      }); 13:    }); 

$('#linetables tbody').on('click', 'tr', function () {     console.log("row clicked");      if ($(this).hasclass('selected')) {         $(this).removeclass('selected');         console.log("removed selected class");      }     else {         table.$('tr.selected').removeclass('selected');         $(this).addclass('selected');         console.log("added selected class");      } }); 

try , confirm events showing in console.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -