EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: galcott on July 15, 2022, 08:46:55 AM



Title: Blur event of combobox
Post by: galcott on July 15, 2022, 08:46:55 AM
I'm having a problem binding to the blur event of the combobox. I need the event to be triggered only when the user leaves the combobox, not when the dropdown arrow is clicked. Using the following code, the blur event is triggered just by clicking the arrow.
Code:
  
// selCategory is a combobox
$('#selCategory').textbox('textbox').bind('blur', (function(e){ GetNextOrderNumber() } ));

I tried this but then it doesn't trigger at all.
Code:
  
$('#selCategory').combobox.bind('blur', (function(e){ GetNextOrderNumber() } ));

Is there a way to trigger the blur only on selection? I certainly hope so otherwise I can't use this component.


Title: Re: Blur event of combobox
Post by: jarry on July 17, 2022, 12:56:46 AM
Call the 'setTimeout' to delay a little time on triggering your blur handler. Please refer to the code below.

Code:
var blurTimer = null;
$('#cc').combobox('textbox').on('focus', function(){
clearTimeout(blurTimer);
}).on('blur', function(){
clearTimeout(blurTimer);
blurTimer = setTimeout(function(){
console.log('blur')
}, 100)

})


Title: Re: Blur event of combobox
Post by: galcott on July 17, 2022, 10:47:37 AM
I don't understand why a timeout would make a difference. Can you please explain that? I tried your code and it doesn't work. You didn't answer my question about whether it's possible to trigger the blur only on selection.