jQuery在对话框中显示动态内容

时间:2014-06-20 15:20:33

标签: jquery dynamic dialog popup

我有这个对话框:

function OpenCopyDialog() {

var $link = $(this); //keep track of the element that was clicked

$("#confirmCopyBox").html("</br><h2>Your are about to copy application number: <span>P</span>@application.Id</h2> </br> <h1> Do you want to continue?</h1>");

$("#confirmCopyBox").dialog({
    resizable: false,
    modal: true,
    title: "Copy Confirmation",
    height: 250,
    width: 400,
    buttons: {
        "Yes": function () {
            $(this).dialog('close');
            callback(true, $link); //pass the reference to the element
        },
        "No": function () {
            $(this).dialog('close');
            callback(false);
        }
    }
});
event.preventDefault();

}

包含这些元素的表格:

<tr>
                        <td><a href="@APPP.GetURL("applicationsFormPageId")?ApplicationId=@application.Id"><span>P</span>@application.Id</a></td>
                        <td>@application.Street</td>
                        <td>13-Jun-2014</td>
                        <td>Incomplete</td>
                        <td>@Html.ActionLink("Delete", "Delete", "YourApplications", new {Id = application.Id }, new { @class = "confirmDelete" })</td>
                        <td>@Html.ActionLink("Copy", "Copy", "YourApplications", new { Id = application.Id }, new { @class = "confirmCopy" })</td>
                        <td><a href="#">download</a></td>
                    </tr>

这个想法是在jQuery弹出窗口中显示动态元素:<span>P</span>@application.Id

因此,每次用户尝试复制或删除时,都会有一个确认弹出窗口,询问他是否确实要删除或复制该元素。

如果您需要额外的信息,请告诉我,但不要向我发送信息。谢谢!

1 个答案:

答案 0 :(得分:0)

这就是我所做的:

var $link = $(this); //keep track of the element that was clicked

var myAppHref = $link.attr('href');
var arrayString = myAppHref.split('/');
var myAppIDclean = arrayString[arrayString.length-1];

$("#confirmDeleteBox").html("</br><h2>You are about to Delete application number: <span>P</span>" + myAppIDclean + "</h2> </br> <h1> Do you want to continue?</h1>");

工作正常。