-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Cannot read property 'className' of undefined #2092
Comments
Bug reports must include a live demo of the problem. Per our contributing guidelines, please create a reduced test case via Plunker, jsFiddle, CodePen or JS Bin, and report back with your link, Bootstrap version, bootstrap-select version, and specific browser and OS details. |
Here is the live demo: https://plnkr.co/edit/xR4pMYKoFwYxXV6B2t5A?p=preview |
…cessing property 'className'
@caseyjhol Oh you have already fixed that. Nice! 👍 |
in bootsrap-select.js line 1063 i change the code and now it works, but a am sure that "!this.multiple" is needed |
@caseyjhol Hello, thanks for the fix. Can you tag this fix? |
I am experiencing the same problem. It occurs in v1.13.2 but not in v1.13.1 so I have downgraded for now. This happens when there are no options in the select element. In my case I was able to narrow the offending line down to the following: bootstrap-select/js/bootstrap-select.js Line 1448 in f629d2f
Where |
I am getting the same error. But in my case the select already has options, and I am checking whether the select contains particular options. If it does, then I am forcing the option to toggle selected, and then I am refreshing the select with this : '$('.selectpicker').selectpicker('refresh');` Here is my code: var modal = $("div#editUserActivity");
modal.find("input[name$=activity_name]").attr('value', data.activity.activity_name);
modal.find('#activity_description').text(data.activity.activity_description);
$.each( data.activity.focuses, function(index, value) {
if (modal.find('#activity_focus option[value="'+ value.id +'"]').length !== 0) {
modal.find('#activity_focus').prop('selected', true).val(value.id);
} else {
modal.find('#activity_focus').append($('<option />').val(value.id).text(value.primary_focus).attr('selected', 'selected'));
}
modal.find('.selectpicker').selectpicker('refresh'); <-- where error is thrown.
}); The error thrown: app.js?id=289c53d38b0c16fad0d1:3502 Uncaught TypeError: Cannot read property 'className' of undefined
at Selectpicker.liHeight (app.js?id=289c53d38b0c16fad0d1:3502)
at Selectpicker.setSize (app.js?id=289c53d38b0c16fad0d1:3700)
at Selectpicker.refresh (app.js?id=289c53d38b0c16fad0d1:4633)
at HTMLSelectElement.<anonymous> (app.js?id=289c53d38b0c16fad0d1:4722)
at Function.each (app.js?id=289c53d38b0c16fad0d1:25190)
at jQuery.fn.init.each (app.js?id=289c53d38b0c16fad0d1:25025)
at jQuery.fn.init.Plugin [as selectpicker] (app.js?id=289c53d38b0c16fad0d1:4702)
at Object.<anonymous> (activities.js?id=4e199cc85f13e6c4bd44:278)
at Function.each (app.js?id=289c53d38b0c16fad0d1:25190)
at Object.<anonymous> (activities.js?id=4e199cc85f13e6c4bd44:271) |
It looks like if I access selectpicker by the the id selector instead of by the class the error is no longer emitted. This seems to solve my problem. Thank you for your time. Christian |
No fix at all! |
Commit: 62a3eac fixes the problem but it should be published a new version! |
Released in v1.13.3! |
I also received same issue in bootstrap file |
When I create a select control without any options and with
width: auto
, I get the following error during initialization:When I remove the
width: auto
option the initialization succeeds but I get the following error when I click on the select control:I am using bootstrap-select v1.13.2
The text was updated successfully, but these errors were encountered: