2017-10-12 70 views
0

我試圖使用.dialog()顯示許可協議時,IE11不斷收到此錯誤。 jQuery UI是v1.11.4。我試圖切換到v1.12.1,它似乎並沒有解決這個問題。結果是該對話框僅在Chrome和Edge上顯示。無法獲取屬性'刪除'的未定義或空引用(jquery-ui)與IE

SCRIPT5007:無法獲取屬性未定義或空引用 '刪除' jQuery的ui.min.js(8,4523)

代碼示例:

<script type="text/javascript"> 
      $(document).ready(function() { 
       $("[id*=LicenseAgreementButton]").click(function() { 
        $("[id*=licenseDialog]").dialog({ 
         dialogClass: "no-close", 
         modal: true, 
         draggable: false, 
         resizable: false, 
         minWidth: 600, 
         title: 'License Agreement', 
         buttons: { 
          'Accept': function() { 
           $("#LicenseAgreementContainer span input").prop("checked", true); 
           $(this).dialog('close'); 
          } 
         } 
        }) 
        $("[id*=licenseDialog]").dialog('open'); 
       }) 
      }); 
     </script> 
<div class="listComponents"> 
      <ul> 
       <asp:ListView ID="ListDcdFiles" runat="server" OnItemDataBound="ListDcdFiles_OnItemDataBound"> 
        <ItemTemplate> 
         <li> 
          <span><%# ((IDcdFileInfo)Container.DataItem).DcdFileTitle %></span> 
          <asp:Panel runat="server" ID="pnlLicenseAgreement" CssClass="clearfix"> 
           <asp:HiddenField runat="server" ID="hfDcdFileId"/> 
           <span class="dcdValidator"><TMA:TMACustomValidator runat="server" ID="vldCbAcceptAgreement" ShowInSummary="True" Enabled="True" ValidationGroup="ItemsList" 
                ErrorMessage="You must accept the license agreement in order to proceed" Text="*" 
                CssClass="validatedMessage" OnServerValidate="vldCbAcceptAgreement_OnServerValidate" /></span> 
           <div class="LicenseAgreementContainer" id="LicenseAgreementContainer"> 
            <asp:CheckBox ID="cbAcceptAgreement" runat="server" Checked="False" Text="Accept License Agreement" CssClass="cbAuthorize" /> 
            <div class="ViewLicenseAgreement"> 
             <input type="button" class="linkButton" ID="LicenseAgreementButton" value="View License Agreement"/> 
            </div> 
            <div id="licenseDialog" style="display:none;"> 
             <div data-role="main" class="LicenseAgreementText"> 
              <asp:Literal runat="server" Mode="PassThrough" ID="htmlLicenseAgreement"></asp:Literal> 
             </div> 
            </div> 
           </div> 
          </asp:Panel> 
         </li> 
        </ItemTemplate> 
       </asp:ListView> 
      </ul> 
     </div> 
+0

licenseDialog位於列表視圖的項目模板中。如果您有多個項目,您將遇到ID衝突。嘗試使用類實例化對話框。 – Dimitri

+0

謝謝@Dimitri,那就像做夢一樣! – Casey

回答

0

好了,多虧了來自@Dimitri的評論我能夠解決這個問題。我只是用類來實例化對話框。

<script type="text/javascript"> 
      $(document).ready(function() { 
       $("#LicenseAgreementButton").click(showDialog); 

       $ldialog = $("#licenseDialog"); 

       $ldialog.dialog({ 
        dialogClass: "no-close", 
        autoOpen: false, 
        modal: true, 
        draggable: false, 
        resizable: false, 
        minWidth: 600, 
        title: 'License Agreement', 
        buttons: { 
         'Accept': function() { 
          $("#LicenseAgreementContainer span input").prop("checked", true); 
          $(this).dialog('close'); 
         } 
        } 
       }); 
      }); 

      var showDialog = function() { 
       $ldialog.show(); 
       $ldialog.dialog("open"); 
      } 
     </script> 
相關問題