Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
618 views
in Technique[技术] by (71.8m points)

hyperlink - jquery link tag enable disable

I want to disable the link during loading, for the code given below

<span id="addlink">"<%= f.add_associated_link('Add Task', @project.tasks.build, :class=>"add") %></span>

I tried it with the codes below but it didn't work

$("#addlink").attr("disabled", "disabled"); 

and

$("a.add").hide();
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
function disableLink(e) {
    // cancels the event
    e.preventDefault();

    return false;
}

When you want to disable it yo call

$('#addlink').bind('click', disableLink);

When you want to enable disabled link you call

$('#addlink').unbind('click', disableLink);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...