Disable the button after pressing it:
$(".menu_clickable").click(function() {
$(this).attr("disabled", "disabled");
$("#main").html('<img src="img/spin.gif" class="spin">');
$("#main").load($(this).attr('rel'), function() {
$(this).removeAttr("disabled");
});
});
You should always activate the link in the callback successto make sure the download is complete, for example:
$.get($(this).attr('rel'), function(html) {
$("#main").html(html);
$(this).removeAttr("disabled");
});
EDIT: Updated based on your comment. If your “action” element is a div, you will have to cancel the click event to prevent the effect from re-clicking and re-link after the download is complete, for example:
function handleClick() {
$(this).unbind("click");
$("#main").html('<img src="img/spin.gif" class="spin">');
$("#main").load($(this).attr('rel'), function() {
$(this).click(handleClick);
});
}
$(".menu_clickable").click(handleClick);
source
share