尝试使用Bootbox确认,但我开始使用bootbox.alert()
对其进行测试,但它无效。
我确认我有 bootstrab.css , bootstrab.js , jquery.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下载内容, 不确定问题在哪里。
答案 0 :(得分:0)
我找到了答案here
这对我有用:
<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>