打开动态创建的链接按钮的JQuery对话框

时间:2014-01-28 09:21:25

标签: jquery

我创建了一个博客。特定的组成员可以在该博客中聊天。每个评论都有一个动态创建的LinkBut​​ton("edit"->text

单击编辑链接按钮后,我想要弹出一个对话框。我尝试了很多但无法继续。请帮忙。

以下是关于我如何尝试此操作的代码。

.cs 文件中的

:(这是我动态创建链接按钮的方式)(我在jquery中使用了LinkBut​​tons类。

LinkButton lnkUpdateComment = new LinkButton();
lnkUpdateComment.ID = "" + objBridgeNotes.BridgeNotesId;
lnkUpdateComment.Text = "edit";
lnkUpdateComment.Attributes.Add("class", "lnkButtons");
lnkUpdateComment.Click += new EventHandler(lnkUpdateComment_Click);

.js 档案:

$(document).ready(function()  {

$(".lnkButtons").live("click", function()  {
$("#divEditComment").dialog("option", "title", "Edit the Comment");
$("#divEditComment").dialog("open");
return true;
});

$(function () {
var dlg = $("#divEditComment").dialog({
    autoOpen: false,
    show: "blind",
    hide: "blind",
    //height: 450,
    minWidth: 400,
    //position: ['right', 210],
    buttons: {
        "Update Note": function () {

            var Updates = btnSubmitComment.replace(/_/g, '$');
            __doPostBack(Updates, '');
        }
    }
});
dlg.parent().appendTo(jQuery("form:first"));
});

});
.aspx 文件中的

    <div id="divEditComment">
<asp:UpdatePanel ID="updComments" runat="server">
    <ContentTemplate>
        <div>
            <table width="100%" style="text-align: center">
                <tr>
                    <td>
                        <div id="divComments" runat="server">
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    </ContentTemplate>

</asp:UpdatePanel>

1 个答案:

答案 0 :(得分:0)

基本上你想要点击每个评论的编辑按钮一个弹出窗口吗?如果单击功能不起作用,只需检查您正在使用的jquery版本,因为已删除了jquery 1.9版本以后的'live'。改为使用on()方法。

  

$(“。lnkBut​​tons”)。on(“click”,function(){});

相关问题