Skip to content
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

TypeError: Cannot read property 'content' of undefined #2436

Closed
ex1st opened this issue Apr 17, 2020 · 4 comments
Closed

TypeError: Cannot read property 'content' of undefined #2436

ex1st opened this issue Apr 17, 2020 · 4 comments

Comments

@ex1st
Copy link
Contributor

ex1st commented Apr 17, 2020

bootstrap: v3.4.1
bootstrap-select: v1.13.13

TypeError: Cannot read property 'content' of undefined
    at Selectpicker.render (bootstrap-select.js:1722)
    at Selectpicker.refresh (bootstrap-select.js:2997)
    at HTMLSelectElement.<anonymous> (bootstrap-select.js:3125)
    at Function.each (jquery.js:367)
    at jQuery.fn.init.each (jquery.js:202)
    at jQuery.fn.init.Plugin [as selectpicker] (bootstrap-select.js:3097)

This error occurs on the render of empty "select" (without "option" elements). Thank you!

if (option.title) {
  titleOptions.text = option.title;
} else if (thisData.content && that.options.showContent) { // <--- this
  titleOptions.content = thisData.content.toString();
  hasContent = true;
} else {
  if (that.options.showIcon) {
    titleOptions.icon = thisData.icon;
  }
  if (that.options.showSubtext && !that.multiple && thisData.subtext) titleOptions.subtext = ' ' + thisData.subtext;
  titleOptions.text = option.textContent.trim();
}
@caseyjhol
Copy link
Member

Bug reports must include a live demo of the problem. Per our contributing guidelines, please create a reduced test case (you can use our preconfigured Plunker), and report back with your link.

@ex1st
Copy link
Contributor Author

ex1st commented Apr 17, 2020

@caseyjhol
Copy link
Member

Seems like it's kind of a fringe case (as there's no reason to call refresh before populating the select, and removing that first refresh() call fixes the bug). In any case, to cover all bases, this should be fixed.

@caseyjhol
Copy link
Member

Released in v1.13.14!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants