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

后端 未结 8 1158
北恋
北恋 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

    0 讨论(0)
  • 2021-02-12 13:52

    I'm working on Ruby on Rails with gem jquery-datatables-rails.

    I update the gem directly from the last commit on GitHub:

    gem 'jquery-datatables-rails', github: "rweng/jquery-datatables-rails", branch: "master"
    

    This work for me, I suppose that that they will release soon a new version of the gem with this commit.

    0 讨论(0)
提交回复
热议问题