【问题标题】:jQuery show dynamic content on a dialogjQuery 在对话框中显示动态内容
【发布时间】:2014-06-20 15:20:32
【问题描述】:

我有这个对话框:

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 弹出窗口中显示动态元素:&lt;span&gt;P&lt;/span&gt;@application.Id

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

如果您需要更多信息,请告诉我,但不要对我投反对票。谢谢!

【问题讨论】:

    标签: jquery dynamic dialog popup


    【解决方案1】:

    这就是我所做的:

    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>");
    

    效果很好。

    【讨论】:

      猜你喜欢
      • 2013-10-29
      • 1970-01-01
      • 2011-03-26
      • 2017-07-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多