Refresh Select2 without triggering change event
See original GitHub issueIn Select2 v4 documentation recommended to reset select by setting value to empty value and triggering event.
$('#id').val('').trigger('change')
But how to reset dropdown select to placeholder without triggering change event and replacing tons of dom elements? Something like
$('#id').select2('refresh')
Issue Analytics
- State:
- Created 8 years ago
- Reactions:13
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Clear select2 without triggering change event - Stack Overflow
I'm trying to clear that select2 without triggering a change event. Is this possible? To clear the select2 I'm using the following code:...
Read more >Events | Select2 - The jQuery replacement for select boxes
Events. Select2 will trigger a few different events when different actions are taken using the component, allowing you to add custom hooks and...
Read more >params object is not present when fire event using .trigger ...
Two things to mention here: - When you want to tell Select2 to update the state of the selected options, you should trigger...
Read more >SCR19: Using an onchange event on a select element ... - W3C
Navigate to the trigger select element, navigate through the options but do not change the value. Check that the matching option values are...
Read more >Options - Select2 - JeeSite
Select2 does not have a custom event (like select2:update ) that can be triggered other than change . You can rely on jQuery's...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top 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
This appear to be an undocumented feature. I found the answer on stackoverflow, use
'change.select2'
http://stackoverflow.com/q/17819709/359284#31856728
I might just document the
change.select2
event as the recommended way to handle this.