[英]JS works on chrome but not on firefox
I have this form that delete an entry and when its clicked its gonna give an alert box 我有这张表格删除一个条目,当它单击时会给一个警告框
This is the HTML 这是HTML
<form class="form-inline" style="display:inline;" role="form" accept-charset="UTF-8" action="http://127.0.0.1:8000/test/1" method="POST">
<input class="hidden" type="submit" value="Delete"></input>
<a class="m-l-sm js-delete-confirm" data-confirm="Are you sure to delete this entry ??" href="#">
<i class="fa fa-times fa-hover" title="" data-placement="top" data-toggle="tooltip" data-original-title="Delete"></i>
</a>
</form>
This is the JS 这是JS
$(document).on('click', '.js-delete-confirm', function() {
console.log('clicked delete');
event.preventDefault();
var choice = confirm(this.getAttribute('data-confirm'));
if (choice) {
$(this).closest('form').submit()
}
});
This works on Google Chrome, but not in Firefox. 这适用于Google Chrome,但不适用于Firefox。 Any idea what did I do wrong?
知道我做错了什么吗? Thanks in advance
提前致谢
Just a hunch, but the missing event
parameter on your click handler might be throwing an error in firefox: 只是预感,但是点击处理程序上缺少的
event
参数可能会在Firefox中引发错误:
// Add event parameter to anonymous click function
$(document).on('click', '.js-delete-confirm', function(event) {
console.log('clicked delete');
event.preventDefault();
var choice = confirm(this.getAttribute('data-confirm'));
if (choice) {
$(this).closest('form').submit()
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.