【发布时间】:2017-02-07 20:52:22
【问题描述】:
关闭对话框时,整个页面会刷新。我该如何避免?请参阅下面的代码:
// delete button
<a id="confirmDelete" class="button orange" href="#" onclick="goDelete(this);">Delete</a>
// function goDelete that opens a dialog.
function goDelete(a) {
var id = a.closest("[data-id]").getAttribute("data-id");
var url = window.location.origin + "/nurse_notes/delete_confirm.jsf?visitId=" + id;
//Create a Div, then append a new iframe inside of it
var dialog = $('<div>').append($('<iframe>').attr('src', url).css({"height":"300","width":"500"}));
$(dialog).dialog({
autoOpen: true,//Means open this now
title: "Delete Confirmation",
width: 550,
height: 375,
modal: true,
position: {my: "center", at: "center",of: "body"}
});
}
问题是,当我单击对话框中的删除或取消按钮时,它会刷新页面。如何在此处停止页面刷新?
HTML 取消 我正在做这样的事情,但它仍然刷新页面:(
我对 jquery 很陌生,正在寻找关于我哪里出错的输入/反馈。谢谢!
【问题讨论】:
-
欢迎来到 Stack Overflow。我怀疑某些东西正在产生错误,请检查您的控制台。这也不是一个非常完整的例子。总体而言,删除确认对话框似乎有点矫枉过正。
标签: jquery jquery-ui jquery-ui-dialog