EasyUI Forum
March 28, 2024, 08:24:02 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Blur event of combobox  (Read 1294 times)
galcott
Newbie
*
Posts: 39


View Profile
« 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.
Logged
jarry
Administrator
Hero Member
*****
Posts: 2260


View Profile Email
« Reply #1 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)

})
Logged
galcott
Newbie
*
Posts: 39


View Profile
« Reply #2 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.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!