Bootstrap模态添加<a href="yoursite.com"> tag instead of <button> tag. Doesn&#39;t work</button></a>

时间:2014-08-12 14:21:32

标签: jquery twitter-bootstrap modal-dialog bootstrap-modal

<a href="#" id="1" class="btn btn-danger btn-xs pull-right delete_group" data-toggle="modal" data-target="#group_delete">Delete</a> 

<div class="modal fade" id="group_delete" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button class="close" data-dismiss="modal">
                        <span aria-hidden="true">&times;</span>
                        <span class="sr-only">Close</span>
                    </button>
                    <h4 class="modal-title">Delete Group</h4>
                </div>

                <div class="modal-body">
                    <h3>Are you sure! you want to delete this group?</h3>
                </div>

                <div class="modal-footer">
                    <button class="btn btn-default" data-dismiss="modal">Cancel</button>
                    <a href="#" class="btn btn-primary" data-dismiss="modal" id="btn_delete_group">Delete</a>
                </div>
            </div>
        </div>
    </div>

app.js文件

$(".delete_group").click(function(event) {
    $('#btn_delete_group').prop('href', '/forum/group/' + event.target.id + '/delete');
});

或者只是这样的事情。

<a href="http://your_site.dev/forum/group/1/delete" class="btn btn-primary" data-dismiss="modal" id="btn_delete_group">Delete</a>

当我单击此删除按钮时隐藏模态但不会转到此链接。 我不知道。

1 个答案:

答案 0 :(得分:0)

已经完成了:)。我在这里犯了一个愚蠢的错误。

<a href="#" class="btn btn-primary" data-dismiss="modal" id="btn_delete_group">Delete</a>

要:

<a href="#" class="btn btn-primary" id="btn_delete_group">Delete</a>

我不需要任何data-dismiss =“modal”