Programmatic control

Events

Select2 will trigger some events on the original select element, allowing you to integrate it with other components. You can find more information on events on the options page.

change is fired whenever an option is selected or removed.

select2:open is fired whenever the dropdown is opened. select2:opening is fired before this and can be prevented.

select2:close is fired whenever the dropdown is closed. select2:closing is fired before this and can be prevented.

select2:select is fired whenever a result is selected. select2:selecting is fired before this and can be prevented.

select2:unselect is fired whenever a result is unselected. select2:unselecting is fired before this and can be prevented.





  

Programmatic access

Select2 supports methods that allow programmatic control of the component.