DataTables TypeError: …draw is not a function

瘦欲@ 提交于 2020-01-15 05:23:30

问题


I'm attempting to use a custom input for searching/filtering a jQuery Datatables table. I'm using jQUery 2.1.1 and DataTables 1.10.4. My code is pretty simple, and mirrors what's in the API docs:

var table = $('#pList').DataTable({  
    "pageLength": 25,
    "lengthChange": false,
    "ajax": 'partsJSON.cfm'

    });

$('#pdb-filter').on( 'keyup', function () {
    console.log(table);
    table.search( this.value ).draw();
} );

When I run the page and make entries in the input, I get the following in the console:

TypeError: table.search(...).draw is not a function 

Followed by:

Object { context: Array[1], selector: Object, tables: O/q.extend/h/<(), table: O/q.extend/h/<(), draw: O/q.extend/h/<(), page: O/q.extend/h/<(), ajax: Object, rows: O/q.extend/h/<(), row: O/q.extend/h/<(), columns: O/q.extend/h/<(), 14 more… }

My reading of that says that "draw" is the fifth element in the table object.

Additionally, when I type the code into the console manually, (without the init options, of course) everything works fine. I get no errors.

Anybody got any ideas?'

来源:https://stackoverflow.com/questions/27067590/datatables-typeerror-draw-is-not-a-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!