簡體   English   中英

jQuery對話框未在瀏覽器中打開

[英]JQuery Dialog not opening in browser

          <link type="text/css" rel="stylesheet" href="scripts/jquery-ui-1.8.5.custom.css" /> 
        <script src="Scripts/jquery-1.4.2.js" type="text/javascript"></script>
        <script type="text/javascript" src="scripts/jquery-ui-1.8.5.custom.min.js"></script> 


     <script type="text/javascript"> 
     function getalert1(Leave_RegisterID) 
            {
                document.getElementById('<%= hdnLeave_RegID.ClientID %>').value = Leave_RegisterID;
                $.fx.speeds._default = 1000;
                $(function () {
                    $('#reason').dialog({
                        autoOpen: false,
                        show: "blind",
                        hide: "explode",
                        display: ''
                    });
                    $('.LeaveReason1').click(function () 
                    {
                        $('#reason').html();
                        $('#reason').dialog('open');
                        return false;
                    });
                });
            }
</script>

我點擊的按鈕:

      <button id="LeaveReason1" class="LeaveReason1" onclick="getalert1('<%# Eval("Leave_RegisterID") %>');" title="Decline">Decline</button>

但是,當我在螢火蟲中調試時,它沒有進入應有的這段代碼:

   $('#reason').html();
   $('#reason').dialog('open');
   return false;

的HTML

 <div id="reason" style="height: 300px; min-height: 109px; width: auto; display:none;" class="ui-dialog-content ui-widget-content"   runat="server">   
            <table width="100%" border="0" cellspacing="0" cellpadding="0">  
                <tr>
                    <td width="25%" class="body_txt" style="padding-right:2px">
                        <asp:Label ID="lblReason" runat="server" Text="Reason:" ></asp:Label>
                    </td>
                    <td width="75%">
                        <asp:TextBox ID="txtReason" Height="40%" Width="100%" MaxLength="200" TextMode="MultiLine" runat="server" CssClass="txt_bx" ></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">&nbsp;</td>
                </tr>                    
                <tr>
                    <td colspan="2" align="center">
                        <asp:Button Width="30%" runat="server" Text="Submit" id="btnSubmit" Height="25px" CssClass="clButton" ></asp:Button>&nbsp;&nbsp;&nbsp;
                    </td>
                </tr>
            </table>
        </div> 

它不在上面給定的代碼內..因為您在另一個click事件中包含了該代碼..因此,要使其正常工作,您必須再次單擊相同的按鈕.....將不起作用。

嘗試這個

  function getalert1(Leave_RegisterID)  // you are calling this function whn click
    {
        document.getElementById('<%= hdnLeave_RegID.ClientID %>').value = Leave_RegisterID;
        $.fx.speeds._default = 1000;
         //$(function () { and no need of ready function here
            $('#reason').dialog({
                autoOpen: false,
                show: "blind",
                hide: "explode",
                display: ''
            });

           // $('.LeaveReason1').click(function () {  again you have a click event here which is not necessary at all.. since the click is already fired by  getalert1()
                $('#reason').html();

                $('#reason').dialog('open');
                return false;

        });
    }
$(document).ready(function(){

//separate your dialog init
$(function() {
    $('#reason').dialog({
         autoOpen: false,
         show: "blind",
         hide: "explode"
    });
});

//only have one click event
$('.LeaveReason1').click(function () 
                {
        document.getElementById('<%= hdnLeave_RegID.ClientID %>').value = Leave_RegisterID;
                $.fx.speeds._default = 1000;

                    $('#reason').html();
                    $('#reason').dialog('open');
                    return false;
                });

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM