2014-01-27 101 views
0

我已经创建了一个博客。特定的群组成员可以在该博客中聊天。每条评论都有一个动态创建的链接按钮(“编辑” - >文本)打开JQuery对话框onclick动态创建链接按钮

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

以下是我如何尝试此操作的代码片段。

在cs文件

:(这是我怎么动态创建的链接按钮) (我在我的jQuery的使用lnkBut​​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")); 
}); 

}); 

in .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> 
</div> 

回答

0

使用on()

$(document).on("click",".lnkButtons", function() { 
// desire action 
}); 

.on()方法附加事件处理程序到当前选定集jQuery对象元件。从jQuery 1.7开始,.on()方法提供了附加事件处理程序所需的全部功能。有关从旧的jQuery事件方法转换的帮助,请参阅.bind().delegate().live()。要删除与.on()绑定的事件,请参阅.off()。要附加只运行一次,然后删除自身的事件,看到.one()

通过 jQuery

+0

没有运气Rituraj。即使在这里也没有进入功能。 –

+0

在你的html里.lnkBut​​tons –

+1

和你的jQuery版本应该是最新的 –

相关问题