Setting the selected value initially and doing a search, shows empty "currently selected"
See original GitHub issueI have set the selected value on the select picker:
$('#myselect').selectpicker('val', '1');
I can see the correct option selected by default (though in the DOM the correspondent select option doesn’t have the selected attribute).
Then I click on the select and to a search via AJAX, and the result says “Currently selected” showing no value, even though I didn’t click on any result so I expect “Currently selected” to be the one initially set.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:9
Top Results From Across the Web
Warning: Use the 'defaultValue' or 'value' props on <select ...
I want to display that dropdown and make that option a default value which was selected by that user last time. I am...
Read more >Solved: Dropdown default value - set to blank value? - Page 2
Solved: I have an edit screen with two dropdowns controls. The first dropdown is Client and the sceond is ClientProject.
Read more >How to set the default value for an HTML <select> element
The default value of the select element can be set by using the 'selected' attribute on the required option. This is a boolean...
Read more >.val() | jQuery API Documentation
Get the current value of the first element in the set of matched elements or ... As of jQuery 3.0, if no options...
Read more >Forms in HTML documents - W3C
The control's "current value" is first set to the initial value. ... The INPUT element is used to create a file select control....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
thanks @calumshep, i made some adjustements to your code:
@calumshep I found that calling
picker.list.replaceOptions(selected);
afterpicker.list.selected = selected;
did solve my problem.