简体   繁体   English

如何成功关闭jquery弹出框?

[英]How can close jquery popup box on success?

In my page I have a link. 在我的页面中,我有一个链接。 After clicking on this link, it's showing a jquery popup box. 单击此链接后,它将显示一个jQuery弹出框。 html code is below : html代码如下:

<input class="modal-state" id="modal-1" type="checkbox" />
   <div class="modal">
     <label class="modal__bg" for="modal-1"></label>
       <div class="modal__inner">
     <label class="modal__close" for="modal-1"></label>    
   <div id="showdoc"></div>    
  </div>

This popup box has a cross (X) icon to close this popup box. 此弹出框带有一个十字(X)图标以关闭此弹出框。 Now I want to close this popup box on the ajax/jquery success method without clicking on the cross (X) icon. 现在,我想关闭ajax / jquery成功方法上的此弹出框,而无需单击十字(X)图标。 How can I do this ? 我怎样才能做到这一点 ?

here is ajax/jquery success method : 这是ajax / jquery成功方法:

success: function (data) {
        $('#result').html('');
        $('#result').show();
        $('#addcontact-img').hide();                            
        getProjectForm(<?php echo $pid; ?>);
        $(".modal__close").dialog( "destroy" );

         $.each( data, function( key, value ) {          
         if(key !== 'error') {
            $('#result').append('<p>'+value+'</p>');              
          }
   });

I used $(".modal__close").dialog( "destroy" ); 我用$(".modal__close").dialog( "destroy" ); but it's now working. 但现在可以了。 If i use $(".modal").fadeOut(500); 如果我使用$(".modal").fadeOut(500); , then on success it closes automatically but again it's not open by clicking on the link. ,然后成功关闭,但自动关闭,但再次无法通过单击链接打开。 I don't know how I can fix it. 我不知道该如何解决。

假设您有关联的对话框.modal ,则需要使用

$(".modal").dialog("destroy");

Try this: 尝试这个:

$(".modal").hide();

If it's a bootstrap modal, then perhaps this'll work: 如果它是引导模式,那么也许可以使用:

$(".modal").modal("hide");

And to check if your checkbox is checked or not, try this: 要检查您的复选框是否已选中,请尝试以下操作:

$(".modal-state").is(":checked") ? $(".modal").hide(): $(".modal").show();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM