Bootstrap模态确认不提交

时间:2017-11-22 09:31:29

标签: javascript jquery twitter-bootstrap-3 bootstrap-modal

我有一个表格,当我提交表格时,我会显示或截取一个模态,确认包含确认文本的提交。当我点击确认提交不会完成但它重新加载页面 任何人都有想法。感谢



$('#submit').click(function(){
    alert('submitting');
    $('#form').submit();
});

<form id="form" name="customer_file_update" method="post" action="XXXXXXX" class="form-horizontal">

{# place of fields#}

<button type="submit" id="customer_file_update_save_and_next" name="customer_file_update[save_and_next]" title="Valider le verdict et continuer" class="btn btn-success btn" data-toggle="modal" data-target="#confirm-verdict-modal" onclick="return false;">Valider le verdict et continuer</button>  
<button .....>XXXX</button>
</form>
   
  
   
   <div class="modal fade" id="confirm-verdict-modal" tabindex="-1" role="dialog" aria-labelledby="confirm-verdict-label" aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <div class="row">
                        <div class="col-md-11">
                            <h5 class="modal-title" id="confirm-verdict-label">XXXXXXXXXXXXXXX</h5>
                        </div>
                        <div class="col-md-1">
                            <button type="button" class="close" data-dismiss="confirm-verdict-label" aria-label="Close">
                                <span aria-hidden="true">&times;</span>
                            </button>
                        </div>
                    </div>
                </div>
                <div class="modal-body">
                    XXXXXXXXXXXXXxXXXXXXXXXXXX ?
                    <p class="text-danger">
                        /!\ XXXXXXXXXXXXXXXXXXXXXX!
                    </p>
                </div>
                <div class="modal-footer"
                    <a href="#" id="submit" class="btn btn-success success">Submit</a>
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Annuler</button>
                </div>
            </div>
        </div>
    </div>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

$('#submit').on('click', function (e){
   e=e || window.e;
   e.preventDefault();
   your_code_open_modal;
});