MVC 4 Razor Object doesn't support property or method 'dataTable'

后端 未结 3 1492
梦毁少年i
梦毁少年i 2021-01-24 18:46

I\'m a noob to MVC, jquery and DataTables. I get a Microsoft Visual Studio warning dialog when I hit F5 to build and bring up the site locally for development/debug:

3条回答
  •  别那么骄傲
    2021-01-24 19:23

    OK,

    Remove the {} between the () of the datatable

    write like this

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

    Fiddle example

    When you want to add options to the datatable you use the {} in order to consume the options

    like this:

    $(document).ready(function() {
    $('#example').dataTable( {
        "bPaginate": false,
        "bLengthChange": false,
        "bFilter": true,
        "bSort": false,
        "bInfo": false,
        "bAutoWidth": false
       } );
    } );
    

    See example

提交回复
热议问题