EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: aswzen on November 12, 2015, 12:16:19 AM



Title: How to disable a textbox button/icons ?
Post by: aswzen on November 12, 2015, 12:16:19 AM
I have to make button/icon in textbox conditionally to appear/render.

How to disable a button/icons in textbox? or at least hiding it.

See this fiddle:
http://jsfiddle.net/t865a9t9/


Thank you in advance


Title: Re: How to disable a textbox button/icons ?
Post by: StefaanEeckels on November 12, 2015, 01:55:22 AM
Hi aswzen,

Is this what you are looking for:

function disableEdit(){
    console.log($('#PROGRAM_NAME').textbox('options'));
    console.log($('#PROGRAM_NAME_2').textbox('options'));
    $('#PROGRAM_NAME').textbox({icons:[{
        iconCls:'icon-add',
         handler: function(e){
            alert('add');
        }},
      ]});
}


This is my first attempt at cloning a jsfiddle, but it seems to have worked: http://jsfiddle.net/hb8pdh4y/1/

Take care,
Stefaan


Title: Re: How to disable a textbox button/icons ?
Post by: aswzen on November 12, 2015, 04:15:10 AM
okay thank you but when i want to enable the icons i have to rewrite the code again..

this way is fine but not efficient

:)


Title: Re: How to disable a textbox button/icons ?
Post by: StefaanEeckels on November 12, 2015, 07:22:38 AM
You could put the button callbacks in a couple of functions:
function disableEdit(){
    $('#PROGRAM_NAME').textbox({icons:[{
        iconCls:'icon-add',
        handler: iconAddAction
      },
    ]});
    $('#PROGRAM_NAME').textbox({editable: false});
}
function enableEdit(){
    $('#PROGRAM_NAME').textbox({icons:[{
        iconCls:'icon-add',
        handler: iconAddAction
      }, {
        iconCls:'icon-edit',
        handler: iconEditAction
      }
   ]});
    $('#PROGRAM_NAME').textbox({editable: true});
}       
function iconAddAction(e){
    alert('add');
}
function iconEditAction(e) {
    alert('edit');
}   

Here's the fiddle: http://jsfiddle.net/hudvkm58/

Take care,
Stefaan


Title: Re: How to disable a textbox button/icons ?
Post by: aswzen on November 12, 2015, 06:56:58 PM
okay...
thank you anyway :D