Javascript Bootbox 回调
Javascript Bootbox Callback
我正在使用 bootbox 来实现灵活的对话框和警报,但遇到了以下回调函数的问题:
var qty= 0;
bootbox.prompt({
title: "Insert qty!",
inputType: 'number',
callback: function (result) {
qty = result;
}
});
alert(qty);
我的警报在引导框对话框打开之前触发。
为什么在引导框对话框之前触发警报?
我怎样才能避免在我的 bootbox-dialog 中得到 0 而不是所需的值?
将警报放在回调中,例如:
var qty= 0;
bootbox.prompt({
title: "Insert qty!",
inputType: 'number',
callback: function (result) {
qty = result;
alert(qty);
}
});
这应该可以解决您的问题 ;)
这个怎么样?
bootbox.prompt({
title: "Insert qty!",
inputType: 'number',
callback: function (result) {
qty = result;
}
}, function (qty) {
alert(qty);
})
我正在使用 bootbox 来实现灵活的对话框和警报,但遇到了以下回调函数的问题:
var qty= 0;
bootbox.prompt({
title: "Insert qty!",
inputType: 'number',
callback: function (result) {
qty = result;
}
});
alert(qty);
我的警报在引导框对话框打开之前触发。 为什么在引导框对话框之前触发警报? 我怎样才能避免在我的 bootbox-dialog 中得到 0 而不是所需的值?
将警报放在回调中,例如:
var qty= 0;
bootbox.prompt({
title: "Insert qty!",
inputType: 'number',
callback: function (result) {
qty = result;
alert(qty);
}
});
这应该可以解决您的问题 ;)
这个怎么样?
bootbox.prompt({
title: "Insert qty!",
inputType: 'number',
callback: function (result) {
qty = result;
}
}, function (qty) {
alert(qty);
})