EasyUI Forum
May 01, 2024, 09:11:54 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: linkbutton 的问题  (Read 41742 times)
iamjxc
Jr. Member
**
Posts: 80


View Profile
« on: July 21, 2011, 06:57:41 AM »

Code:
// 下面这样注册事件, 当按钮不可用时, doXxx() 方法不会被调用
<a id="xxx" class="easyui-linkbutton" onclick="doXxx()">XXX</a>

// 下面这样注册事件, 当按钮不可用时, doXxx() 方法还是会被调用!
// 我们期望是不会被调用
$("#xxx").click(doXxx);
Logged
wzlcm
Newbie
*
Posts: 3


View Profile Email
« Reply #1 on: August 17, 2011, 05:54:22 PM »

楼主,顶上去,我也遇到同样的问题了。怎么弄都不好使,环境是 1.2.4 ,Firfox
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #2 on: August 17, 2011, 07:30:05 PM »

When you set up the 'click' handler, you can add some code to check if the linkbutton is disabled. The code looks like this:
Code:
$('#xxx').click(function(){
  if ($(this).linkbutton('options').disabled == false){
    // do your action
  }
});
Logged
wzlcm
Newbie
*
Posts: 3


View Profile Email
« Reply #3 on: August 24, 2011, 06:14:30 PM »

When you set up the 'click' handler, you can add some code to check if the linkbutton is disabled. The code looks like this:
Code:
$('#xxx').click(function(){
  if ($(this).linkbutton('options').disabled == false){
    // do your action
  }
});
我对 linkbutton做了修改,可直接屏蔽click事件:
Code:

    function setDisabled(target, disabled) {

        var state = $.data(target, "linkbutton");
        if (disabled) {
            state.options.disabled = true;
            var href = $(target).attr("href");
            if (href) {
                state.href = href;
                $(target).attr("href", "javascript:void(0)");
            }
            if (target.onclick) {
                state.onclick = target.onclick;
                target.onclick = null;
            }
            //事件处理
        var events = $(target).data("events");
        if(events){
            var clicks = events.click;//暂时只处理click事件
            state.events = state.events||[];
            $.extend(state.events, clicks);
            $(target).unbind("click");
        }
           
            $(target).addClass("l-btn-disabled");
        } else {
            state.options.disabled = false;
            if (state.href) {
                $(target).attr("href", state.href);
            }
            if (state.onclick) {
                target.onclick = state.onclick;
            }
            if (state.events) {
            for ( var i=0;i<state.events.length;i++){
            $(target).bind(state.events[i].type,state.events[i].handler);
                }
            }
            $(target).removeClass("l-btn-disabled");
        }
    };   



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!