【问题标题】:Linking update action to the close button of jquery dialog将更新操作链接到 jquery 对话框的关闭按钮
【发布时间】:2020-03-24 08:51:14
【问题描述】:

我想将一个事件链接到 jquery 对话框关闭按钮。 我会尽力描述情况: 我有一种议程,有 5 天(周一至周五),每天可以有 20 行。 当您单击特定日期的 rox 时,会出现一个 jquery 对话框,其中包含一个 iFrame(链接到议程_lestijd.aspx) 用户可以通过页面中的按钮(agenda_lestijd.aspx)放置数据并保存数据。 当我关闭 jQuery 对话框时,我喜欢启动 btnUpdate 事件,这意味着只有特定日期的行操作会被更新,而不是整个页面。 此时我将 btnUpdate 按钮放在页面上,它可以正常工作....但我希望有一种方法可以使用 jquery 对话框的关闭按钮。

HTML code + jquery:
<script type="text/javascript" src="js/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.ui/1.8.6/jquery-ui.min.js"></script>
<link type="text/css" rel="Stylesheet" href="http://ajax.microsoft.com/ajax/jquery.ui/1.8.6/themes/smoothness/jquery-ui.css"/>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.ui/1.8.6/jquery-ui.min.js"></script>
<link type="text/css" rel="Stylesheet" href="http://ajax.microsoft.com/ajax/jquery.ui/1.8.6/themes/smoothness/jquery-ui.css"/>
<script type="text/javascript">
$(document).ready(function () {
$('a#pop').live('click', function (e) {
e.preventDefault();
var page = $(this).attr("href")
var pagetitle = $(this).attr("title")
var $dialog = $('<div></div>')
.html('<iframe style="border: 0px; " src="' + page + '" width="100%" height="100%"></iframe>')
.dialog({
autoOpen: false,
modal: true,
height: 800,
width: 1200,
title: pagetitle,
close: ReloadPage,
position: ["center", 20]
});
$dialog.dialog('open');
});
});
function ReloadPage() {
alert('test');
}
</script>

this is one of the updatepanels:
<asp:UpdatePanel ID="UpdatePanel2" runat="Server" UpdateMode="Conditional">
<ContentTemplate>
<tr>
<asp:Button ID="btnUpdate" UseSubmitBehavior="false" runat="server" onClick="btnUpdate_Click" Text ="Update" />
<asp:Label ID="labWeekOverzichtLestijd1_2" runat="server" Text=""></asp:Label>
<asp:Label ID="labWeekOverzichtLestijd2_2" runat="server" Text=""></asp:Label>
<asp:Label ID="labWeekOverzichtLestijd3_2" runat="server" Text=""></asp:Label>
<asp:Label ID="labWeekOverzichtLestijd4_2" runat="server" Text=""></asp:Label>
<asp:Label ID="labWeekOverzichtLestijd5_2" runat="server" Text=""></asp:Label>
</tr>
</ContentTemplate>
</asp:UpdatePanel>

I fill the agenda with a function in the codebehind:

For i = 1 To 20
fillLestijd (lestijd_index:=i, lestijden:=lestijden)
Next

Private Sub fillLestijd(ByVal lestijd_index As Integer, ByVal lestijden As Array) //here is also the link for activating the jquery dialog
labWeekOverzichtLestijd = "<td class='" + Session("dagkleur") + "'><span class='" + titelkleur + "'><a id='pop' href='agenda_lestijd.aspx?" & Session("weeknummer") & "&datum=" & datum & "&lestijd=" & var & "' title='Lestijden'><img src= 'graphics/edit1.png'></a>"
end sub

This is the code for the update of just one row:
Protected Sub btnUpdate_Click(sender As Object, e As EventArgs)
fillLestijd(lestijd_index:=aantal, lestijden:=lestijden)
Select Case aantal
Case 1
UpdatePanel1.Update()
Case 2
UpdatePanel2.Update()
Case 3
UpdatePanel3.Update()
Case 4
UpdatePanel4.Update()
Case 5
UpdatePanel5.Update()
Case 6
UpdatePanel6.Update()
Case 7
UpdatePanel7.Update()
Case 8
UpdatePanel8.Update()
Case 9
UpdatePanel9.Update()
Case 10
UpdatePanel10.Update()
Case 11
UpdatePanel11.Update()
Case 12
UpdatePanel12.Update()
Case 13
UpdatePanel13.Update()
Case 14
UpdatePanel14.Update()
Case 15
UpdatePanel15.Update()
Case 16
UpdatePanel16.Update()
Case 17
UpdatePanel17.Update()
Case 18
UpdatePanel18.Update()
Case 19
UpdatePanel19.Update()
Case 20
UpdatePanel20.Update()
End Select
End Sub

Can I get help for this topic?? Thxs

【问题讨论】:

    标签: jquery dialog


    【解决方案1】:

    试试这个:

     $( ".selector" ).dialog({
          beforeClose: function( event, ui ) {
    // do whatever you want before dialog closes
    }
        });
    

    欲了解更多信息,请查看this

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-02-27
      • 2014-08-02
      • 2012-11-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-06
      • 1970-01-01
      相关资源
      最近更新 更多