带有laravel 4.0的Bootstrap 3.1

时间:2014-05-13 14:40:39

标签: laravel-4 twitter-bootstrap-3

单击显示确认对话框的删除按钮时显示确认对话框时出现问题,并且在没有单击确认对话框中的按钮的情况下提交表单。

我正在使用bootstrap和laravel。这是代码。

<div class="modal fade" id="confirmDelete" role="dialog" aria-labelledby="confirmDeleteLabel" aria-hidden="true">
<div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h4 class="modal-title">Delete Confirmation</h4>
        </div>
        <div class="modal-body">
            <p>Are you sure you want to delete this data(s) ?</p>
        </div>
        <div class="modal-footer">
            <button type="button" class="btn default" data-dismiss="modal">Cancel</button>
            <button type="button" class="btn btn-danger" id="confirm">Delete</button>
        </div>
    </div>
</div>

$('#confirmDelete').on('show.bs.modal', function (e) {
            // Pass form reference to modal for submission on yes/ok
            var form = $(e.relatedTarget).closest('form');
            $(this).find('.modal-footer #confirm').data('form', form);
        });

        <!-- Form confirm (yes/ok) handler, submits form -->
        $('#confirmDelete').find('.modal-footer #confirm').on('click', function(){
            $(this).data('form').submit();
        });


{{ Form::open(array('route' => array('subscription.delete.all'), 'method' => 'delete')) }}
<button class='btn btn-xs btn-danger' type='submit' data-toggle="modal" data-target="#confirmDelete">
            <i class='glyphicon glyphicon-trash'></i> Delete
        </button>
{{ Form::close() }}

2 个答案:

答案 0 :(得分:1)

在你的模态之上加上这个

<a href="#" type="button" class="btn btn-default btn-danger" data-toggle="modal" data-target="#confirmDelete">
delete

并在您的模态代码中更改按钮

<button type="button" class="btn btn-danger" id="confirm">Delete</button>

删除按钮代码

    {{ Form::open(array('route' => array('subscription.delete.all')......

答案 1 :(得分:0)

更改按钮(表单内)类型从“提交”到“按钮”