bootstrap modal 自动关闭


jquery ui 太丑陋了,现在换成bootstrap modal,请问大大如何在表单正确提交后自动关闭模态框?
源码


 <script>
                var myIntegral = 0;
                $(document).ready(function(){
                   $(".link").click(function(){
                       var id = $(this).attr('rel');
                       if(is_login){
                           $("#modal").dialog({
                               width:500,
                               height:300,
                               modal: true,
                               buttons:{
                                   '确定':function(){
                                       var data = $("#div form").serialize();
                                       $.ajax({
                                           url:'url&id='+id,
                                           data:data,
                                           type:'POST',
                                           dataType:'json',
                                           success:function(data){
                                               if(data.ret == 0) {
                                                   alert(data.message);
                                                   $("#modal").dialog('close');
                                               }else{
                                                   alert(data.message);
                                               }
                                           }
                                       });

                                   },
                                   '取消':function(){
                                       $(this).dialog('close');
                                   }
                               }
                           });                     
                       }else{
                            alert('需要登录后操作');
                            location.href ='login.php';
                       }

                   });
</script>

修改后


 <script>
    $(document).ready(function() {
      $(".link").click(function() {
        var id = $(this).attr('rel');
        if (is_signin) {
          $("#modal .modal-body > form").attr("action", "url&id=" + id);
          $("#modal").modal();
        } else {
          alert('需要登录后操作');
          location.href = 'login.php'
        }
      });
    });
    </script>

jquery bootstrap

一字文番团 10 years, 8 months ago

setTimeout(function(){$("#modal").modal("hide")},2000);

上反而减少 answered 10 years, 8 months ago

Your Answer