kartik-v / yii2-widget-select2

Enhanced Yii2 wrapper for the Select2 jQuery plugin (sub repo split from yii2-widgets).
http://demos.krajee.com/widget-details/select2
Other
323 stars 145 forks source link

Cant select/deselect all #290

Closed dfuse-dev closed 5 years ago

dfuse-dev commented 5 years ago

Steps to reproduce the issue

  1. Dropdown with multiple select
  2. Click on "Select all"

Expected behavior and actual behavior

It should select all values in dropdown and instead of that it throws this error:

Uncaught TypeError: Cannot read property 'element' of undefined
    at HTMLLIElement.<anonymous> (select2-krajee.min.js:10)
    at Function.each (jquery.js:362)
    at jQuery.fn.init.each (jquery.js:157)
    at HTMLSpanElement.<anonymous> (select2-krajee.min.js:10)
    at HTMLSpanElement.dispatch (jquery.js:5206)
    at HTMLSpanElement.elemData.handle (jquery.js:5014)

Environment

Browsers

Operating System

Libraries

Isolating the problem

spiderbbc commented 5 years ago

same problem, attentive to any comments

floor12 commented 5 years ago

i have the same problem with 'select all' link.

vanterbit commented 5 years ago

i have the same problem. My data: yii2 version 2.0.24 select2-krajee.js - @version 2.1.4 jquery.js - jQuery JavaScript Library v3.4.1 PHP @version 7.3.8

Console log: select2-krajee.js:71 Uncaught TypeError: Cannot read property 'element' of undefined at HTMLLIElement. (select2-krajee.js:71) at Function.each (jquery.js:367) at jQuery.fn.init.each (jquery.js:202) at HTMLSpanElement. (select2-krajee.js:69) at HTMLSpanElement.dispatch (jquery.js:5237) at HTMLSpanElement.elemData.handle (jquery.js:5044)

floor12 commented 5 years ago

Roll back to latest stable version 2.1.3 from dev-master and 'select all' will be working again.

kartik-v commented 5 years ago

Thanks for the report guys - this seems to have happened after the update to the source third party select 2 plugin. Will check on this.

kartik-v commented 5 years ago

Resolved with the above latest commit.

abelwamana commented 3 months ago

Hi, i have the same problem, and a use the last version, in my case is when i try select many elements. when I select few elements it works fine. 5select2-krajee.js:47 Uncaught TypeError: Cannot read properties of null (reading 'length') at HTMLLIElement. (select2-krajee.js:47:30) at Function.each (jquery.js:385:19) at jQuery.fn.init.each (jquery.js:207:17) at HTMLSpanElement. (select2-krajee.js:45:90) at HTMLSpanElement.dispatch (jquery.js:5466:27) at elemData.handle (jquery.js:5270:28)

abelwamana commented 3 months ago

I already found the solution, followed the error and changed the line: if (opts.length && opts[1]) to if (opts && opts.length && opts[1])