保存按钮单击jquery后,ModalPopup关闭

时间:2013-01-17 08:29:50

标签: php javascript jquery ajax codeigniter

我正在研究代码点火器..在我的视图页面中,我有一个模态弹出窗口。在modalpopup中,我已经把form.so我想要的是当用户点击保存按钮..模型弹出关闭通过jquery ..

这是我的保存和关闭按钮...如果我单击关闭按钮,模型关闭,但因为保存按钮我已经控制到jquery所以我想关闭那里我不知道

    <a href="#" class="btn" data-dismiss="modal">Close</a> 
   <a id = "save" class="btn x" data-dismiss="modal">Save changes</a>



   <script type="text/javascript">
    $('#save').click(function() { //  $("#form").serialize()

var check_no = $('#check_no').val();
var form_data = {
        check_no: $('#check_no').val(),


};



$.ajax({
    url: "<?php echo site_url('checkDetailsController/addCheckDetails'); ?>",
    type: 'POST',
    data: form_data,
    dataType: 'json',
    success: function(msg) {
        if(msg.res == 1)
        {
            alert('true')

        }
        else{
            alert("false");          
          }


    }
});

return false;
     });


  </script>

2 个答案:

答案 0 :(得分:1)

保存功能必须使用$('#dialog')。dialog(“close”);而不是$(this).dialog('close')。这会导致调用附加到对话框对象的close方法。

答案 1 :(得分:0)

如果您使用jqueryUI中的对话框,则可以使用按钮选项。

$('#yourcontainer').dialog({
        buttons : {
            // Save and close button
            'Save' : function () {
                // your javascript code for saving
                $(this).dialog('close');
            },
            // Cancel button
            'Close' : function () {
                $(this).dialog('close');
            }
        },
        // and your other settings
    });
相关问题