“Uncaught TypeError: Cannot use 'in' operator to search for 'length' in ” triggered by Datatables plugin and jQuery 1.11.3

后端 未结 8 1160
北恋
北恋 2021-02-12 13:17

I\'m using the jQuery Datatables plugin to enable pagination, sorting and searching with my tables. The elements are showing up but not working, and the pagination only sometime

8条回答
  •  死守一世寂寞
    2021-02-12 13:50

    Whilst unrelated to DataTables, I came across this "cannot use in operator to search for length" error. This was the main Google result for the error so just wanted to post my issue as a response in case it helps anyone else.

    I had:

    ApplicationIDs: $.map(".application-checkbox:checked", function (checkedApplicationCheckbox, i) {
    

    I'd forgotten to wrap my selector with the $ so the fix was to make sure I was passing the actual jQuery elements as the first argument to map and not just a string...

    ApplicationIDs: $.map($(".application-checkbox:checked"), function (checkedApplicationCheckbox, i) {
    

    I'm almost embarrased to post this ;)

    Cheers

提交回复
热议问题