【发布时间】:2017-04-12 15:02:02
【问题描述】:
尝试使用 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 下载内容, 不知道问题出在哪里。
【问题讨论】:
-
控制台中有什么?
-
我在控制台中看不到任何与 bootbox 相关的内容我使用了 firefox 控制台 --> js 并使用过滤器在 Bootbox 上进行过滤
-
您正在收听表单提交按钮,并且您已为其分配了一个操作。看看这个类似问题的答案:stackoverflow.com/a/27328602/185034
-
如果页面是由 JS(Angular 等)渲染的,你可以试试 $('.btn').live('click',function(){ ...
-
尝试使用
.live和.addEventListener,但不起作用
标签: javascript jquery twitter-bootstrap bootbox