EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: arma on October 15, 2014, 03:00:36 PM



Title: Add event to combobox
Post by: arma on October 15, 2014, 03:00:36 PM
Hi,

How could i extend combobox so it could trigger on method clear() ? I have a lot of custom combobox with checkbox formatter http://www.jeasyui.com/forum/index.php?topic=3588.msg8202#msg8202 (http://www.jeasyui.com/forum/index.php?topic=3588.msg8202#msg8202), when i clear a combobox i would also want to untick the checkbox, so i need to extend to add onclear event.

Thanks


Title: Re: Add event to combobox
Post by: jarry on October 15, 2014, 05:08:52 PM
Please override the 'clear' method of combobox. When calling the 'clear' method. The 'onClear' event fires.
Code:
(function(){
    var clear = $.fn.combobox.methods.clear;
    $.extend($.fn.combobox.methods, {
        clear: function(jq){
            return jq.each(function(){
                clear.call($.fn.combobox.methods, $(this));
                var opts = $(this).combobox('options');
                if (opts.onClear){
                    opts.onClear.call(this);
                }
            })
        }
    })
})(jQuery);