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");
}
};