bootbox模态框的API
在需要模态框时执行
bootbox.confirm({});
bootbox.alert({});
bootbox.prompt({});
详细的API文档在这里!如下面的例子:前提是bootstrap已经集成进项目了!因为bootbox是基于bootstrap样式的。
如下:
bootbox.confirm({
size: "small",
message: "Are you sure?",
callback: function(result){ /* result is a boolean; true = OK, false = Cancel*/ }
})
bootbox.prompt({
size: "small",
title: "What is your name?",
callback: function(result){ /* result = String containing user input if OK clicked or null if Cancel clicked */ }
})
下面是常用的API:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
message | String | Element | Text (or markup) displayed in the dialog. Required for alert, confirm, and custom dialogs | ||||||
title | String | Element | Adds a header to the dialog and places this text (or markup) in an Required for prompts | ||||||
callback | Function | Required for confirm and prompt An alert callback should not supply an argument; it will be ignored if it does: Confirm and prompt callbacks must supply an argument for the result; for confirm, it will be a or Default: | ||||||
onEscape | Boolean | Function | Allows the user to dismiss the dialog by hitting ESC, which will invoke this function.
Default: | ||||||
show | Boolean | Whether the dialog should be shown immediately. Default: | ||||||
backdrop | Boolean | Whether the dialog should be have a backdrop or not. Also determines whether clicking on the backdrop dismisses the modal.
Default: * When this value is set to | ||||||
closeButton | Boolean | Whether the dialog should have a close button or not. Default: | ||||||
animate | Boolean | Animate the dialog in and out (requires a browser which supports CSS animations). Default: | ||||||
className | String | An additional class to apply to the dialog wrapper. Default: | ||||||
size | String | Adds the relevant Bootstrap modal size class to the dialog wrapper. Valid values are Requires Bootstrap 3.1.0 or newer. Default: | ||||||
buttons | Object | Buttons are defined as JavaScript objects. The minimum shortform requirement to define a button is: The complete definition of a button object is:
Each of the available button options can be overridden to use custom content (text or HTML) and CSS styles. For example:
You cannot override the callbacks for the alert, confirm, and prompt dialog's buttons. |