我有这个代码:
HTML:
<div id="dialog-first"></div>
<div id="dialog-second"></div>
<div id="dialog-third"></div>
<div id="menu">
<ul>
<li id="first"><a href="#first">first</a></li>
<li id="second"><a href="#second" class="confirm">second (need confirm)</a></li>
<li id="third"><a href="#third" class="confirm">third (need confirm)</a></li>
</ul>
</div>
Javascript 第 1 部分:
$('li a.confirm').live('click', function (e) {
e.preventDefault();
var id = $(this).parent('li').attr('id');
$('#dialog-' + id).dialog({
dialogClass: 'ui-dialog-confirm',
buttons: {
"Confirm": function () {
/*window.location.href = $(this).attr('href');*/
$(this).dialog("close");
},
"Cancel": function () {
$(this).dialog("close");
}
}
});
});
Javascript 第 2 部分:
$('#menu li').each(function () {
var id = $(this).attr('id');
$('#dialog-' + id).on("dialogclose", function (event, ui) {
//How can I check what user clicked, Confirm or Cancel ???
//Is it possible
console.log(event);
});
});
如何检查用户点击、确认或取消?
如果可能的话,我只想更改 Javascript 第 2 部分。