0
jQueryの確認ボックスがすごく見えるので、他のすべてと一緒に使うことができれば、ブラウザのURLをリダイレクトするような面倒で醜悪なハッキングもなく、イベントやインラインハンドラをクリックする必要があります。jQueryクリーン確認ダイアログのアイデア - しかし、onclickはeventHandlerから呼び出されたときに新しいonclick関数をトリガーしません
だから、私は、そのオブジェクトのなeventHandlerにアクセスするとき、それはインラインハンドラを更新するために、後半にすでに把握このEDIT新しいバージョン jQuery confirm dialog idea to capture click events before onclick can get triggered
を思い付きました。 方法はありますか?
コード:
$(function(){
$(".needsFancyConfirm").each(function(index, ele){
ele=$(ele);
ele._onclick=ele.attr("onclick");
ele.attr("onclick", "return false;"); //preventDefault would do the same imho
ele.bind("click.foo",function(){
$("#dialog").dialog({
bgiframe: true,
height: 300,
modal: true,
buttons: {
SubmitFormWithAllOldOnclickEvents: function() {
$(this).dialog('close');
ele.attr("onclick",ele._onclick);
ele.unbind("click", "click.foo");
console.info(ele.attr('onclick') + " <-- just to make sure what is written in Onclick, now we will execute it");
console.info($("#coolIdea")[0].onclick() + " <-- this returns false - it should return the set old onclick e.g. alert Wow u managed to execute me");
}
}
});
});
});
});