简体   繁体   English

我想在点击删除图片时显示弹出模式

[英]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.

相关问题 我想创建一个flickr画廊,当我单击图片显示时,弹出带有图片及其标签,标题,照片的证件 - I want create a flickr gallery and when i click on image show pop up with the image and its tags, tittle, photo id Codeigniter 当我单击删除时,如果单击是或否,我想弹出通知 - Codeigniter when i click delete i want pop up notification if if click yes or not 如何修复单击删除时不显示的删除模式 - How do i fix my delete modal that doesnt show up when i click delete 如何在Laravel 5中以模态/弹出方式显示图像? - How to show an image in a modal/pop up in Laravel 5? 我想添加一个弹出模式框 - I want to add a pop up modal box 当我使用 Javascript 和 JQuery 单击显示按钮时,我想在显示模式中显示我的 td 的图像数据,但找不到 src 的路径 - I want to display the image data of my td in the show modal when I click on the show button using Javascript and JQuery but path of the src not found 使用 Modal 时无法弹出图像 - Image not able to pop up when using Modal 以模式显示数据单击“ Web网格列”后弹出 - To show Data in modal Pop up after click on Web Grid Column 我开发了一个api,我希望它重定向到其他php页面,并在我单击api文件中的按钮时弹出模式 - I developed a api and i want it to redirect to other php page and pop up the modal as i click the button in api file 单击图像时弹出屏幕 - pop up screen when click on image
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM