以下是我当前的代码 TechHunter。当我单击是按钮时,没有任何反应,弹出窗口看起来也没有使用 CSS 格式化。
<?php do { ?>
<div data-userid="<?php echo $row_users['id']; ?>" class="userTableBody">
<div id="idRow"><?php echo $row_users['id']; ?></div>
<div id="usernameRow"><?php echo $row_users['username']; ?></div>
<div id="useremailRow"><a href="mailto:someone@example.com"><?php echo $row_users['email']; ?></a></div>
<div id="actionRow"><a href="#" class="toPopupButton actionButton">Delete</a></div>
</div>
<?php } while ($row_users = mysql_fetch_assoc($users)); ?>
<div id="dialog-confirm" title="Delete user?">
<p><span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>Are you sure you want to delete this user?</p>
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"> </script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.9.2/jquery-ui.js"> </script>
<script type="text/javascript" src="../include/js/script.js"></script>
这是我在 jsfiddle.net 上从您的示例中获取的 script.js 中的 JQuery 代码位置
$(function() {
$( "#dialog-confirm" ).dialog({
resizable: false,
height:250,
modal: true,
autoOpen:false,
buttons: {
"Yes": function() {
var $this = $(this);
$.ajax({
url:'http://www.example.com/action/deleteUser.php?id='+$( this ).data('userid'),
success:function(){$this.dialog( "close" )}
});
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
$( ".toPopupButton" ).click(function() {
var userid = $(this).parentsUntil('.userTableBody').parent().data('userid');
console.log(userid);
$( "#dialog-confirm" ).data('userid',userid).dialog( "open" );
});
});
我在这里错过了什么吗?