dianping/cat · error · Error
confirm requires a callback
Error message
confirm requires a callback
What it means
Unlike alert, bootbox.confirm requires a callback (it must be a function) because the dialog's whole purpose is reporting the user's choice: the callback receives true (confirm) or false (cancel/escape). With no callable callback the result would be unusable, so it throws before rendering.
Source
Thrown at cat-home/src/main/webapp/assets/js/uncompressed/bootbox.js:341
exports.confirm = function() {
var options;
options = mergeDialogOptions("confirm", ["cancel", "confirm"], ["message", "callback"], arguments);
/**
* overrides; undo anything the user tried to set they shouldn't have
*/
options.buttons.cancel.callback = options.onEscape = function() {
return options.callback(false);
};
options.buttons.confirm.callback = function() {
return options.callback(true);
};
// confirm specific validation
if (!$.isFunction(options.callback)) {
throw new Error("confirm requires a callback");
}
return exports.dialog(options);
};
exports.prompt = function() {
var options;
var defaults;
var dialog;
var form;
var input;
var shouldShow;
var inputOptions;
// we have to create our form first otherwise
// its value is undefined when gearing up our options
// @TODO this could be solved by allowing message to
// be a function instead...View on GitHub (pinned to e815e74d4c)
Solutions
- Supply a function: bootbox.confirm('Proceed?', function(result){ if (result) doIt(); }).
- Check the callback exists when it is dynamic: if (typeof cb === 'function') bootbox.confirm(msg, cb); else bootbox.alert(msg).
- If upgrading to bootbox 5+, note confirm may be used promise-style — but verify the bundled version first.
Example fix
// before
bootbox.confirm('Delete item?'); // nothing happens with the answer
// after
bootbox.confirm('Delete item?', function (result) {
if (result) deleteItem();
}); Defensive patterns
Strategy: type-guard
Validate before calling
if (typeof onDecide !== 'function') {
throw new Error('caller must supply a decision handler');
}
bootbox.confirm(message, onDecide); Type guard
function isConfirmCallback(fn) {
return typeof fn === 'function';
} Prevention
- confirm always needs a function callback
- Handle both true and false results inside the callback
- Check the bootbox version: 5.x allows promise style, 4.x does not
When it happens
Trigger: bootbox.confirm('Proceed?'); bootbox.confirm('Proceed?', 'handleIt'); bootbox.confirm({message: '...'}) with a missing or non-function callback property; passing a callback that a wrapper failed to forward.
Common situations: Copy-pasted an alert() call and changed only the message; refactoring removed the callback during cleanup; assuming the promise-style API of bootbox 5+ (which returns a promise and makes callback optional) while running bootbox 4.x where it is mandatory.
Related errors
- prompt requires a callback
- Please specify a message
- alert requires callback property to be a function when provi
- prompt requires a title
- Please supply an object of options
AI-assisted analysis of dianping/cat@e815e74d4c (2026-08-14).
Data as JSON: /api/errors/f5801e1a83cae09b.
Report an issue: GitHub.