EasyUI Forum
October 17, 2025, 05:17:42 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: READONLY Textbox enabling onClickIcon event [Solved]  (Read 19768 times)
devnull
Sr. Member
****
Posts: 431


View Profile
« on: May 09, 2015, 06:45:20 PM »

Hi;

Is it possible to have the icon & click event enabled when the testbox is disabled ??

I thought I saw a post resolving this but have searched and can't seem to find it.

Thanks
« Last Edit: May 10, 2015, 07:58:48 PM by devnull » Logged

-- Licensed User --
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: May 09, 2015, 07:20:18 PM »

A disabled textbox will disable all the icon clicking handlers. To enable the icon clicking, you have to get the icon and bind events by yourself.
Code:
$('#tt').textbox({
    disabled:true,
    icons:[{
        iconCls:'icon-ok',
        handler:function(){
            //...
        }
    }]
}).textbox('getIcon',0).bind('click',function(){
    console.log('click icon')
})
Logged
devnull
Sr. Member
****
Posts: 431


View Profile
« Reply #2 on: May 09, 2015, 07:28:04 PM »

My apologies, I meant READONLY not enabled, can this be done ?
Logged

-- Licensed User --
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: May 10, 2015, 04:14:39 AM »

If you just want to prevent from editing the textbox and allow the user to click the icons, please set the 'editable' property to false.
Code:
$('#tt').textbox({
    editable:false,
    icons:[{
        iconCls:'icon-ok',
        handler:function(){
            //...
        }
    }]
})
Logged
devnull
Sr. Member
****
Posts: 431


View Profile
« Reply #4 on: May 10, 2015, 04:48:45 AM »

Thanks, I tried that, but I cannot get the onClickIcon() event to fire at all.

I would also have expected the icon to be greyed out and to highlight on mouseover ?!

http://jsfiddle.net/seKvb/47/

Logged

-- Licensed User --
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #5 on: May 10, 2015, 04:56:30 PM »

Setting the 'iconCls' property only allows the textbox displaying a background icon on the component, no events occur. Please use the 'icons' property instead. The updated example is available from http://jsfiddle.net/seKvb/48/
Logged
devnull
Sr. Member
****
Posts: 431


View Profile
« Reply #6 on: May 10, 2015, 07:50:05 PM »

Oops, OK thanks.

How can I get the parent textbox value from the iconhandler event as $(this).textbox() does not work:

Code:
  $('#XXX').textbox({
    icons:[{
      iconCls:'aicon-go',
      handler: function(){
        var val = $(this).textbox('getValue');
        if(val.length < 1) return false;     
      }
    }]
  })
Logged

-- Licensed User --
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #7 on: May 10, 2015, 07:55:45 PM »

Please try this code.
Code:
$('#XXX').textbox({
    icons:[{
        iconCls:'aicon-go',
        handler:function(e){
            var val = $(e.data.target).textbox('getValue');
            console.log(val)
        }
    }]
})
Logged
devnull
Sr. Member
****
Posts: 431


View Profile
« Reply #8 on: May 10, 2015, 07:58:36 PM »

Thanks so much.
Logged

-- Licensed User --
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!