[英]I want to show pop up modal when click on delete image
Jquery code is Jquery代码是
$(".confirmDialog").live("click", function (e) {
// e.preventDefault(); use this or return false
var url = $(this).attr('href');
$("#dialog-confirm").dialog({
autoOpen: false,
resizable: false,
height: 170,
width: 350,
show: { effect: 'drop', direction: "up" },
modal: true,
draggable: true,
buttons: {
"OK": function () {
$(this).dialog("close");
window.location = url;
},
"Cancel": function () {
$(this).dialog("close");
}
}
});
$("#dialog-confirm").dialog('open');
return false;
}); });
HTML.cshtml code is HTML.cshtml代码是
<div id="dialog-confirm" style="display: none">
<p>
<span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>
Are you sure to delete ?
</p>
button is 按钮是
when I using button it is deleting data 当我使用按钮时,它正在删除数据
@Html.ActionLink("Delete", "Delete", new { id = item.Sid }, new { @class = "confirmDialog" })
But not showing popup. 但没有显示弹出窗口。 and How to delete and show popup when using image.
以及如何在使用图像时删除和显示弹出窗口。
将jquery代码放在document.ready中并使用.click而不是.live
Document.ready(function(){ $(".confirmDialog").click(function(){ }); });
As Rory McCrossan and Raphael Mayer in your comments has suggested to use ".on" instead of ".live" as this has been removed from newer versions of jQuery. 正如你的评论中的Rory McCrossan和Raphael Mayer建议使用“.on”而不是“.live”,因为这已从较新版本的jQuery中删除。
$(".confirmDialog").on("click", function (e) {
...
...
});
Here is some documentation from jQuery: 以下是jQuery的一些文档:
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.