Title: linkbutton 的问题
Post by: iamjxc on July 21, 2011, 06:57:41 AM
// 下面这样注册事件, 当按钮不可用时, doXxx() 方法不会被调用 <a id="xxx" class="easyui-linkbutton" onclick="doXxx()">XXX</a> // 下面这样注册事件, 当按钮不可用时, doXxx() 方法还是会被调用! // 我们期望是不会被调用 $("#xxx").click(doXxx);
Title: Re: linkbutton 的问题
Post by: wzlcm on August 17, 2011, 05:54:22 PM
楼主,顶上去,我也遇到同样的问题了。怎么弄都不好使,环境是 1.2.4 ,Firfox
Title: Re: linkbutton 的问题
Post by: stworthy 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: $('#xxx').click(function(){ if ($(this).linkbutton('options').disabled == false){ // do your action } });
Title: Re: linkbutton 的问题
Post by: wzlcm 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: $('#xxx').click(function(){ if ($(this).linkbutton('options').disabled == false){ // do your action } });
我对 linkbutton做了修改,可直接屏蔽click事件: 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"); } };
|