EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: korenanzo on October 20, 2015, 07:34:58 AM



Title: combobox/datebox: how to manage click on the icon (arrow)
Post by: korenanzo on October 20, 2015, 07:34:58 AM
Hi,

I need to manage the click event on the down arrow (or calendar icon )  button, on comboboxes and dateboxes.

Following http://www.jeasyui.com/forum/index.php?topic=4790.0 , I tried something like:
Code:
$.extend($.fn.combobox.defaults, {
 
icons:[{
  handler:function(e){
console.log ("STICLICK");
}
}]
})

but it doesn't work.

So, which is the correct way to reach my goal?

thanks,

Ric



Title: Re: combobox/datebox: how to manage click on the icon (arrow)
Post by: jarry on October 20, 2015, 05:44:52 PM
You can hide the original down-arrow icon and customize the new 'icons' to achieve the same functionality.
Code:
$.extend($.fn.combobox.defaults, {
hasDownArrow: false,
icons: [{
iconCls:'combo-arrow',
handler:function(e){
var target = e.data.target;
var panel = $.data(target, 'combo').panel;
if (panel.is(':visible')){
$(target).combo('hidePanel');
} else {
var p = $(target).closest('div.combo-panel'); // the parent combo panel
$('div.combo-panel:visible').not(panel).not(p).panel('close');
$(target).combo('showPanel');
}
$(target).combo('textbox').focus();
}
}]
})

If you only want to get the click event on the down-arrow icon, please use the 'onClickIcon' event instead.
Code:
$('#cc').combobox({
onClickIcon: function(index){
var icon = $(this).combobox('getIcon', index);
if (icon.hasClass('combo-arrow')){
console.log('clicked the down arrow icon.')
}
}
})


Title: Re: combobox/datebox: how to manage click on the icon (arrow)
Post by: korenanzo on October 20, 2015, 11:57:57 PM
Quote
If you only want to get the click event on the down-arrow icon, please use the 'onClickIcon' event instead.

Oh, that's my way!

It works, thanks

It seems an undocumented event :O I haven't found it on the manual ...

I can suppose there could be lots of them... is there a way to find them?

Thanks, RIc


Title: Re: combobox/datebox: how to manage click on the icon (arrow)
Post by: jarry on October 21, 2015, 01:37:59 AM
The combobox extends from textbox. All the events defined in textbox can be used in the combobox.


Title: Re: combobox/datebox: how to manage click on the icon (arrow)
Post by: korenanzo on October 21, 2015, 01:44:38 AM
Ah ok, my fault :)