您好我有以下页面
<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
});
}
});
问题是,confirmdialog从不显示(???)。我在同一页面上添加了javascript但是我遇到了unblocklink的问题。
答案 0 :(得分:0)
好的,我找到了解决问题的解决方案:
从主页导航到blockedusers页面时,我需要按照以下方式进行:
$('#blockedusers').click(function(e) {
window.location.href = "blockedusers.php";
});
只有这样才能在DOM中提供确认框。
这不起作用:
$.mobile.changePage('blockedusers.php');
希望这个解决方案可以帮助更多人。