EasyUI Forum
December 05, 2025, 03:26:42 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: How to disable a textbox button/icons ?  (Read 11852 times)
aswzen
Sr. Member
****
Posts: 287


Indonesian

aswzen
View Profile WWW Email
« 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
Logged

Regards,
Sigit

- Indonesian jEasyUI Facebook page : https://www.facebook.com/groups/jeasyuiid/
StefaanEeckels
Newbie
*
Posts: 12


View Profile
« Reply #1 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
Logged
aswzen
Sr. Member
****
Posts: 287


Indonesian

aswzen
View Profile WWW Email
« Reply #2 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

Smiley
Logged

Regards,
Sigit

- Indonesian jEasyUI Facebook page : https://www.facebook.com/groups/jeasyuiid/
StefaanEeckels
Newbie
*
Posts: 12


View Profile
« Reply #3 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
Logged
aswzen
Sr. Member
****
Posts: 287


Indonesian

aswzen
View Profile WWW Email
« Reply #4 on: November 12, 2015, 06:56:58 PM »

okay...
thank you anyway Cheesy
Logged

Regards,
Sigit

- Indonesian jEasyUI Facebook page : https://www.facebook.com/groups/jeasyuiid/
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!