嗨,我有以下页面
<div data-role="page" id="blockedusers">
<?php
include 'homeheader.php';
?>
<div data-role="header">
<a href="#" id="logoutbutton" data-role="button" data-icon="home">Log Uit</a>
<h1>Blocklijst</h1>
</div><!-- /header -->
<div data-role="content">
<div class="grid_outer" id="grid_outer_blocklist" style="width: 295px; margin-left: auto; margin-right: auto;">
<div class="grid_inner" id="grid_inner_blocklist">
<h2 class="h2_header">Geblokkeerde gebruikers</h2>
<?php
show_blocked_users($blockedusers);
?>
</div>
</div>
</div>
<div data-role="navbar">
<ul>
<li>
<a href="#" data-rel="back" data-icon="back">terug</a>
</li>
</ul>
</div><!-- /navbar -->
<div data-role="footer">
<h4>Blocklijst</h4>
</div>
</div><!-- /content -->
<div data-role="dialog" id="confirmbox">
<div data-role="header" data-icon="false">
<h1>Bevestig</h1>
</div><!-- /header -->
<div data-role="content">
<h3 id="confirmMsg">Bevestig</h3>
<br>
<center>
<a href="#" class="btnConfirmYes" data-role="button" data-icon="check" data-mini="true" data-inline="true"> Yes </a>
<a href="#" class="btnConfirmNo" data-role="button" data-rel="back" data-icon="delete" data-mini="true" data-inline="true">No</a>
</center>
</div>
</div>
我在外部 js 文件中有以下 javascript
$(document).on('pagebeforeshow', '#blockedusers', function() {
alert('pagebeforeshow blockedusers');
$('[id=unblocklink]').click(function(e) {
e.preventDefault();
var userid = $(this).attr('userid');
alert('unblocklink clicked userid ' + userid);
showConfirm("Weet je zeker dat je deze gebruiker wilt deblokkeren?", function() {
$.ajax({
async : false,
url : "../php/process_unblock_user.php?userid=" + userid,
success : function(data) {
if (data != "") {
// in case of error
alert(data);
} else {
alert("Gebruiker gedeblokkeerd!");
window.location.reload(true);
}
}
});
});
});
// confirm dialog
function showConfirm(msg, callback) {
alert('showing dialog1');
$("#confirmMsg").text(msg);
$("#confirmbox .btnConfirmYes").on("click.confirmbox", function() {
$("#confirmbox").dialog("close");
callback();
});
$("#confirmbox .btnConfirmNo").off("click.confirmbox", function(r) {
});
alert('showing dialog2');
$.mobile.changePage('#confirmbox', {
allowSamePageTransition : true
});
}
});
问题是,确认对话框从不显示(???)。我在同一页面上添加了 javascript,但后来我遇到了 unblocklink 问题。