-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allowClear gives "Uncaught TypeError: Cannot read property 'id' of undefined" when used on single select boxes with ajax load #3497
Comments
I'm going to take a guess and say that you are not using Can you expand upon the issue you are facing by adding a few more pieces of information to your bug report?
The contributing guide contains a useful section with a few questions which can help us track down the bug and speed up the process of finding a fix for it. The creation of an isolated test case would also be useful. |
Select2: v4.0.0, jQuery: v1.11.1, Linux, Chrome
Clicking on clear icon raises exception, on: Function: Code:
Why: Workaround:
|
+1 for pgasidlo description, there is no check that this.placeholder is defined in AllowClear.prototype._handleClear |
This is a duplicate of #3016, you can see the error if you add |
@pgasidlo , you're a lifesaver. +1 ! |
@pgasidlo Thank a lot buddy! |
using @pgasidlo's work around the initial placeholder will be overridden after clear |
Still having this issue in version 4.0.3, because the
or set it globally: |
See detail at select2/select2#3497
After following the above solution, when I am selecting an option after doing clear all once, I am getting two selected options : 1) which i have selected and 2) -Select- |
@glalwani2 it may be a known bug. Please search the open issues. |
i can also confirm, that the bug is still here in v4.0.3. @akositey proposed fix to add blank placeholder is a working workaround. |
Is this not documented anywhere on the site? Also, you know that the current version is 4.0.6-rc.0, right? |
@alexweissman i can confirm, that the same behaviour is in the version 4.0.6-rc.0 too. and i did not ee anywhere mentioned that in case you use allowClear you must also provide placeholder option. |
Ok, I will reopen this so that I remember to update the docs. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Bug still exists in 4.0.13! |
@ManuelHaas Can confirm to this. The bug still persists. |
The problem still persists
|
We are using ajax to load data remotely to a single select box. It works just fine, but if allowClear is enabled (set to true) a javascript error is encountered in select2 when the clear mark is clicked in the select box - and the value is not cleared from the box.
The error is:
Uncaught TypeError: Cannot read property 'id' of undefined
S2.define.AllowClear._handleClear @ select2.js:1721
S2.define.Utils.Decorate.calledMethod @ select2.js:571
(anonymous function) @ select2.js:1681
n.event.dispatch @ jquery-2.1.4.min.js:3
n.event.add.r.handle @ jquery-2.1.4.min.js:3
The text was updated successfully, but these errors were encountered: