確認ボックスとして使用する関数を作成しました。
$.fn.confirmation = function(message, color) {
$('.notification').css("background", color);
$('.notification').html(message + "<br/><a href='#' id='sure'>I am sure</a> or <a href='#cancel' id='cancel'>Cancel</a>");
$('.notification').slideDown();
$(document).on("click", '.notification a', function(event){
if($(this).attr("id") == "sure") {
$('.notification').slideUp();
return true;
} else if($(this).attr("id") == "cancel") {
$('.notification').slideUp();
return false;
}
});
};
私の問題は、常に false を返し、on イベントを待たないことです。
ユーザーがクリックするまでJQueryを強制的に待機させるにはどうすればよいですか?