EasyUI Forum
April 08, 2026, 10:31:56 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: Extend disable / enable checkbox method  (Read 10006 times)
Aod47
Jr. Member
**
Posts: 85


View Profile
« on: December 20, 2019, 03:07:39 AM »

Hello,

I created panel that contain many checkbox, radio.
I would like to disable / enable all checkbox in panel by extend panel method.
I apply a code from this topic https://www.jeasyui.com/forum/index.php?topic=3038.0 but it does'n work.

Here is modified code

Code:
$.extend($.fn.panel.methods, {
            enableCbx: function(jq) {
                return jq.each(function() {
                    var t = $(this);
                    t.find('input')._propAttr('enabled', 'enabled');
                    var plugins = ['checkbox', 'radiobutton'];
                    for (var i = 0; i < plugins.length; i++) {
                        var plugin = plugins[i];
                        var r = t.find('.' + plugin + '-f');
                        if (r.length && r[plugin]) {
                            r[plugin]('enable');
                        }
                    }
                })
            },
            disableCbx: function(jq) {
                return jq.each(function() {
                    var t = $(this);
                    t.find('input')._propAttr('disabled', 'disabled');
                    var plugins = ['checkbox', 'radiobutton'];
                    for (var i = 0; i < plugins.length; i++) {
                        var plugin = plugins[i];
                        var r = t.find('.' + plugin + '-f');
                        if (r.length && r[plugin]) {
                            r[plugin]('disable');
                        }
                    }
                })
            }
        })

Could your please advice where I missing? Thank you.
Logged
jarry
Administrator
Hero Member
*****
Posts: 2307


View Profile Email
« Reply #1 on: December 25, 2019, 11:37:01 PM »

Please use this code instead.
Code:
$.extend($.fn.panel.methods, {
enableCbx: function(jq){
return jq.each(function(){
$(this).find('.checkbox-f').checkbox('enable')
})
},
disableCbx: function(jq){
return jq.each(function(){
$(this).find('.checkbox-f').checkbox('disable')
})
}
})
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!