I'm trying to do some logic after user completes a selection and moves away from a bootstrap multi-select dropdown.
I tried hooking into the blur event:
<select id="select1" multiple="multiple" class="form-control" data-bind="options: availableValues, selectedOptions: selectedValues, multiselect: {
includeSelectAllOption: true
}, event: { blur: $root.onBlur}">
</select>
Defining a onBlur function in my viewModel:
onBlur: function(){
alert('OnBlur');
}
But it never kicks-in. I even tried setting the event binding directly without the $root.onBlur
, just blur: onBlur
but didn't work.
Here is a sample JS fiddle:
https://jsfiddle.net/gtzatrL2/
Am I missing something? or is the blur event not applicable to bootstrap multi-selects?
The reason I want to hook into blur is because I have some backend logic to do through Ajax after ALL items have been selected. If I subscribe to my observableArray changes it will trigger my backend call for each item added which is not what I want.