EasyUI Forum
May 07, 2024, 10:48:35 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: Add event to combobox  (Read 6545 times)
arma
Full Member
***
Posts: 110


View Profile
« 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, when i clear a combobox i would also want to untick the checkbox, so i need to extend to add onclear event.

Thanks
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


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

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!