【发布时间】:2017-02-11 08:03:12
【问题描述】:
我使用 bootstrap-confirmation 创建了以下弹出框确认,并希望触发下拉列表的此确认 onClose 事件。虽然我可以在每次关闭下拉列表时获取控制台日志,但我也无法在关闭时显示确认窗口。有没有手动触发的方法?
@Html.DropDownListFor(m => m.GroupId, new SelectList(Model.Groups, "Value", "Text"),
"Select", new { data_toggle = "confirmation" })
$('#GroupId').on('select2:close', onClose)
function onClose(evt) {
console.log('close...'); //this line is executed
//I think the problem is related to this part. I might be using it on the wrong section
var Confirmation = require('confirmation-popover');
var confirm = new Confirmation({
rootSelector: '[data-toggle=confirmation]',
// other options
selector: '[data-toggle="confirmation"]',
title: 'Are you sure?',
placement: 'top',
btnOkIcon: 'glyphicon glyphicon-ok',
btnOkClass: 'btn btn-sm btn-success',
btnOkLabel: 'Yes',
btnCancelIcon: 'glyphicon glyphicon-remove',
btnCancelClass: 'btn btn-sm btn-danger',
btnCancelLabel: 'No'
});
confirm.show(el);
}
【问题讨论】:
-
$("#GroupId").on("change",function(e){ onClose(e);}) 应该可以,请尝试。
-
问题与调用方法onClose无关,实际上问题与如何触发引导确认有关,我不知道如何正确定义它以便手动触发。有什么想法吗?
-
ethaizone.github.io/Bootstrap-Confirmation/# 什么时候触发呢?在下拉菜单中选择选项?
-
在onClose函数中。
标签: javascript jquery asp.net asp.net-mvc twitter-bootstrap