Select2 trigger "select2:select"
See original GitHub issueI have a script that does the following code:
select2input.on('select2:select', function(e, e2) {
if (e.params !== undefined && e.params.data !== undefined) {
div.html(e.params.data.unidade_medida_txt);
anotherinput.val(FloatField.format(e.params.data.valor_compra)).trigger('change');
}
});
I need to manually call “select2: select” and pass the data “e.params”, how do?
Something like:
select2input.trigger('select2:select', ...pass params...);
Thank you.
Issue Analytics
- State:
- Created 8 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Events | Select2 - The jQuery replacement for select boxes
Select2 will trigger a few different events when different actions are taken using the component, allowing you to add custom hooks and perform...
Read more >Select2 auto trigger event change - Stack Overflow
I just need set the new selected option without trigger the change event. Any alternative to .select2("val", "x") while using select2 plugin?
Read more >params object is not present when fire event using .trigger ...
- When you want to tell Select2 to update the state of the selected options, you should trigger the `change` event. - When...
Read more >Public jQuery events - 1112
What events will Select2 trigger? ; change: Triggered whenever an option is selected or removed. ; select2:close: Triggered whenever the dropdown is closed....
Read more >Select2 3.5.3
Select2 3.5.3. Select2 is a jQuery based replacement for select boxes. It supports searching, remote data sets, and infinite scrolling of results.
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 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
Hey @invious, I found this thread while struggling with this myself.
Calling val and then change does not seem to trigger the select2:select, you have to fire it yourself. The doc for this is here.
This is how I did it:
HTH
Chaining
trigger('change')
withtrigger('select2:select')
allowed me to successfully call my select2:select event.