dianping/cat · error · Error
prompt requires a callback
Error message
prompt requires a callback
What it means
bootbox.prompt requires a callback function, mandatory for the same reason as confirm: the entered value is only delivered via callback (string, or false/null when cancelled/dismissed). Validation runs after the title check and throws when options.callback is missing or not a function.
Source
Thrown at cat-home/src/main/webapp/assets/js/uncompressed/bootbox.js:440
each(checkedItems, function(_, item) {
value.push($(item).val());
});
break;
}
return options.callback(value);
};
options.show = false;
// prompt specific validation
if (!options.title) {
throw new Error("prompt requires a title");
}
if (!$.isFunction(options.callback)) {
throw new Error("prompt requires a callback");
}
if (!templates.inputs[options.inputType]) {
throw new Error("invalid prompt type");
}
// create the input based on the supplied type
input = $(templates.inputs[options.inputType]);
switch (options.inputType) {
case "text":
case "textarea":
case "email":
case "date":
case "time":
case "number":
case "password":
input.val(options.value);View on GitHub (pinned to e815e74d4c)
Solutions
- Pass a function as the second argument (or callback property): bootbox.prompt('Your name:', function(v){ ... }).
- Handle cancellation inside the callback: result === false or null means dismissed — code accordingly.
- Do not rely on the return value for the user input; capture it in the callback closure.
Example fix
// before
var name = bootbox.prompt('Enter your name:'); // no callback, throws
// after
bootbox.prompt('Enter your name:', function (name) {
if (name === null) return; // dismissed
save(name);
}); Defensive patterns
Strategy: type-guard
Validate before calling
if (typeof cb !== 'function') cb = function () {};
bootbox.prompt('Enter a value:', cb); Type guard
function isPromptCallback(fn) {
return typeof fn === 'function';
} Prevention
- prompt never returns the value synchronously — use the callback
- Treat null/false callback results as dismissal
- Always pass the callback as the second argument or callback property
When it happens
Trigger: bootbox.prompt('Your name:'); bootbox.prompt('Your name:', 'save'); bootbox.prompt({title: 'Your name:'}) with no callback; passing an unbound method reference that is undefined.
Common situations: Assuming prompt returns the value synchronously (it does not — pre-bootbox-5 it returns a jQuery/XHR-like dialog object); refactoring that dropped the callback; mixing up argument order (callback first, title second).
Related errors
- confirm requires a callback
- prompt requires a title
- Please specify a message
- alert requires callback property to be a function when provi
- invalid prompt type
AI-assisted analysis of dianping/cat@e815e74d4c (2026-08-14).
Data as JSON: /api/errors/e711942927a0d7d2.
Report an issue: GitHub.