Hi,
I’m looking for a way to detect user action vs programmed action.
How can I catch if the user click on the X to unselect an item (AllowClear)?
Note I’m using single selection
$('#myfield').on('select2:select', function(e) {
if(e?.params?.originalEvent?.originalEvent) {
console.log('user action');
} else {
console.log('program action');
}
});
I also tried
$('#myfield').on('select2:unselecting', function (e) {
if(e?.params?.originalEvent?.originalEvent) {
// user action
console.log('user action');
} else {
// programatically trigger
console.log('program action');
}
});
Both log result ended to program action so this mean no originalEvent is attached to AllowClear.
This is similar to this fix but for AllowClear
0909d8c