带有Laravel 4.0的Bootstrap 3.1 [英] Bootstrap 3.1 with laravel 4.0

查看:61
本文介绍了带有Laravel 4.0的Bootstrap 3.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have problem to display confirmation dialog box when I click the delete button it show the confirmation dialog and also submit the form without clicking the button in confirmation dialog box.

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

I'm using bootstrap and laravel. here is the code.

<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() }}

推荐答案

在模态顶部添加

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

并在模式代码中更改按钮

and in your modal code change the button

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

通过您的删除按钮代码

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

这篇关于带有Laravel 4.0的Bootstrap 3.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆