EasyUI Forum
May 05, 2024, 04:44:49 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Combobox with Clear Icon,  (Read 3727 times)
Aod47
Jr. Member
**
Posts: 83


View Profile
« on: October 23, 2019, 05:53:42 PM »

From

https://www.jeasyui.com/forum/index.php?topic=3786.0

I tried that code with combobox.

Clear icon appear when use arrow key when select item option.
But when select item with mouse. Clear icon does not show.


How to bind change event instead keyup?

Thank you for advice.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: October 23, 2019, 08:23:22 PM »

Try this code to attach a clear icon on the combobox component.
Code:
$('#cc').combobox({
icons: [{
iconCls: 'icon-clear',
handler: function(e){
$(e.data.target).combobox('clear').combobox('textbox').focus();
}
}],
onChange: function(value){
if (value){
$(this).combobox('getIcon', 0).css('visibility','visible')
} else {
$(this).combobox('getIcon', 0).css('visibility','hidden')
}
}
})
Logged
Aod47
Jr. Member
**
Posts: 83


View Profile
« Reply #2 on: October 24, 2019, 08:04:34 PM »

Thank you sir.  Smiley

for complete. I added below code for prevent display x button when load success but no item select.

Code:
onLoadSuccess: function() { 
var v = $(this).combobox('getValue');
if (v) {
$(this).combobox('getIcon', 0).css('visibility', 'visible');
} else {
$(this).combobox('getIcon', 0).css('visibility', 'hidden');
}
}
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!