引导箱警报不起作用

问题描述 投票:0回答:1

尝试使用 Bootbox 确认,但我开始使用

bootbox.alert()
进行测试,但它不起作用。

我确认我已在 Web 标头中包含 bootstrab.cssbootstrab.jsjquery.js 和 -bootbox.min.js

 <link href="{% static "css/patients.css" %}" rel="stylesheet">
 <link href="{% static "css/bootstrap.css" %}" rel="stylesheet">

<link href="{% static "css/bootstrap.min.css" %}" rel="stylesheet">
<link href="{% static "css/jquery-ui.min.css" %}" rel="stylesheet">
<link href="{% static "css/bootstrap.min.css" %}" rel="stylesheet">
<link href="{% static "css/bootstrap-datetimepicker.min.css" %}" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>  
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootbox.js/4.4.0/bootbox.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

这是我的按钮,我想在单击时生成警报:

<form id='form'  name='delete'  action="{% url 'delete_person' person.id %}"
          method='POST'>

    {% csrf_token %}

    <button type='submit' class='btn btn-xs btn-link icon'><i  class='glyphicon glyphicon-remove'></i></button>
</form>

在同一个 .html 文件中,我有:

<script type="text/javascript">
    $(document).ready(function(){
           $('.btn').on('click' , function(){
                 bootbox.alert("hello there!");
                         });
                 });</script>

当我点击按钮时什么也没发生,

我确认我的浏览器能够从 CDN 下载内容, 不确定问题出在哪里。

javascript jquery twitter-bootstrap bootbox
1个回答
0
投票

我找到了答案在这里

这对我有用:

   <script type="text/javascript">
$(document).ready(function(){
$(".btn#del").click(function(e) {
    e.preventDefault();
    var lHref = $('form#form1').attr('action');
    bootbox.confirm("Are you sure?", function(confirmed) {
        if(confirmed) {
            window.location.href = lHref;
        }
    });
});
})
</script>

<button type='submit'  onclick="bootbox.confirm();" id="del" class='btn btn-xs btn-link icon'><i  class='glyphicon glyphicon-remove'></i></button>
    </form></td>
© www.soinside.com 2019 - 2024. All rights reserved.