bootstrap之BootstrapDialog
模態彈框:
<div class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
<p>One fine body…</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
Dialog彈出層:
BootstrapDialog.alert('I want banana!');
Examples
Simplest
只提供資訊顯示,並保持所有其他事情預設。
BootstrapDialog.show({ message: 'Hi Apple!' });
Dialog Title
BootstrapDialog.show({ title: 'Say-hello dialog', message: 'Hi Apple!' });
操作對話標題
BootstrapDialog.show({ title: 'Default Title', message: 'Click buttons below.', buttons: [{ label: 'Title 1', action: function(dialog) { dialog.setTitle('Title 1'); } }, { label: 'Title 2', action: function(dialog) { dialog.setTitle('Title 2'); } }] });
操作對話資訊
BootstrapDialog.show({ title: 'Default Title', message: 'Click buttons below.', buttons: [{ label: 'Message 1', action: function(dialog) { dialog.setMessage('Message 1'); } }, { label: 'Message 2', action: function(dialog) { dialog.setMessage('Message 2'); } }] });
載入遠端頁面(1)
BootstrapDialog.show({ message: $('<div></div>').load('remote.html') });
載入遠端頁面 (2)
BootstrapDialog.show({ message: function(dialog) { var $message = $('<div></div>'); var pageToLoad = dialog.getData('pageToLoad'); $message.load(pageToLoad); return $message; }, data: { 'pageToLoad': 'remote.html' } });
Buttons
BootstrapDialog.show({ message: 'Hi Apple!', buttons: [{ label: 'Button 1' }, { label: 'Button 2', cssClass: 'btn-primary', action: function(){ alert('Hi Orange!'); } }, { icon: 'glyphicon glyphicon-ban-circle', label: 'Button 3', cssClass: 'btn-warning' }, { label: 'Close', action: function(dialogItself){ dialogItself.close(); } }] });
操作Buttons
通過bootstrapdialog建立按鈕有一些額外的功能:
$button.toggleEnable(true|false);
$button.enable(); // 相當於 $button.toggleEnable(true);
$button.disable(); // 相當於 $button.toggleEnable(false);
$button.toggleSpin(true|false);
$button.spin(); // 相當於 $button.toggleSpin(true);
$button.stopSpin(); // 相當於 $button.toggleSpin(false);
BootstrapDialog.show({ title: 'Manipulating Buttons', message: function(dialog) { var $content = $('<div><button class="btn btn-success">Revert button status right now.</button></div>'); var $footerButton = dialog.getButton('btn-1'); $content.find('button').click({$footerButton: $footerButton}, function(event) { event.data.$footerButton.enable(); event.data.$footerButton.stopSpin(); dialog.setClosable(true); }); return $content; }, buttons: [{ id: 'btn-1', label: 'Click to disable and spin.', action: function(dialog) { var $button = this; // 'this' here is a jQuery object that wrapping the <button> DOM element. $button.disable(); $button.spin(); dialog.setClosable(false); } }] });
按鈕的熱鍵
試著按下面的按鈕。
最後一個按鈕被禁用,所以沒有事情發生,當按下熱鍵。
請注意,如果您的對話方塊中有一些需要鍵盤操作的元件,可能會出現衝突,您可以嘗試下一個示例。
BootstrapDialog.show({ title: 'Button Hotkey', message: 'Try to press some keys...', onshow: function(dialog) { dialog.getButton('button-c').disable(); }, buttons: [{ label: '(A) Button A', hotkey: 65, // Keycode of keyup event of key 'A' is 65. action: function() { alert('Finally, you loved Button A.'); } }, { label: '(B) Button B', hotkey: 66, action: function() { alert('Hello, this is Button B!'); } }, { id: 'button-c', label: '(C) Button C', hotkey: 67, action: function(){ alert('This is Button C but you won\'t see me dance.'); } }] });
建立 dialog 例項
BootstrapDialog.show(...) 只是一個快捷方式,如果你需要對話方塊例項,用“新”。
// Using init options
var dialogInstance1 = new BootstrapDialog({ title: 'Dialog instance 1', message: 'Hi Apple!' }); dialogInstance1.open(); // Construct by using setters var dialogInstance2 = new BootstrapDialog(); dialogInstance2.setTitle('Dialog instance 2'); dialogInstance2.setMessage('Hi Orange!'); dialogInstance2.setType(BootstrapDialog.TYPE_SUCCESS); dialogInstance2.open(); // Using chain callings var dialogInstance3 = new BootstrapDialog() .setTitle('Dialog instance 3') .setMessage('Hi Everybody!') .setType(BootstrapDialog.TYPE_INFO) .open();
事實上BootstrapDialog.show(...) 也將返回建立的對話方塊例項。
// You can use dialogInstance later.
var dialogInstance = BootstrapDialog.show({ message: 'Hello Banana!' });
Button with identifier
var dialog = new BootstrapDialog({ message: 'Hi Apple!', buttons: [{ id: 'btn-1', label: 'Button 1' }] }); dialog.realize(); var btn1 = dialog.getButton('btn-1'); btn1.click({'name': 'Apple'}, function(event){ alert('Hi, ' + event.data.name); }); dialog.open();
較大的對話方塊
預設情況下,對話方塊的大小是 'size-normal' 或 BootstrapDialog.SIZE_NORMAL, 但你可以通過設定選項的 'size' 的'size-large' 或BootstrapDialog.SIZE_LARGE.
BootstrapDialog.show({ size: BootstrapDialog.SIZE_LARGE, message: 'Hi Apple!', buttons: [{ label: 'Button 1' }, { label: 'Button 2', cssClass: 'btn-primary', action: function(){ alert('Hi Orange!'); } }, { icon: 'glyphicon glyphicon-ban-circle', label: 'Button 3', cssClass: 'btn-warning' }, { label: 'Close', action: function(dialogItself){ dialogItself.close(); } }] });
More dialog sizes
Please note that specifying BootstrapDialog.SIZE_WIDE is equal to using css class 'modal-lg' on Bootstrap Modal.
BootstrapDialog.show({ title: 'More dialog sizes', message: 'Hi Apple!', buttons: [{ label: 'Normal', action: function(dialog){ dialog.setTitle('Normal'); dialog.setSize(BootstrapDialog.SIZE_NORMAL); } }, { label: 'Small', action: function(dialog){ dialog.setTitle('Small'); dialog.setSize(BootstrapDialog.SIZE_SMALL); } }, { label: 'Wide', action: function(dialog){ dialog.setTitle('Wide'); dialog.setSize(BootstrapDialog.SIZE_WIDE); } }, { label: 'Large', action: function(dialog){ dialog.setTitle('Large'); dialog.setSize(BootstrapDialog.SIZE_LARGE); } }] });
更多資訊
bootstrapdialog支援顯示豐富的內容,所以你甚至可以使用一個視訊剪輯你的對話方塊中的訊息。
var $textAndPic = $('<div></div>'); $textAndPic.append('Who\'s this? <br />'); $textAndPic.append('<img src="./images/pig.ico" />'); BootstrapDialog.show({ title: 'Guess who that is', message: $textAndPic, buttons: [{ label: 'Acky', action: function(dialogRef){ dialogRef.close(); } }, { label: 'Robert', action: function(dialogRef){ dialogRef.close(); } }] });
Dialog closable / unclosable
If option 'closable' is set to false, the default closing behaviors will be disabled, but you can still close the dialog by using dialog.close().
BootstrapDialog.show({ message: 'Hi Apple!', closable: false, buttons: [{ label: 'Dialog CLOSABLE!', cssClass: 'btn-success', action: function(dialogRef){ dialogRef.setClosable(true); } }, { label: 'Dialog UNCLOSABLE!', cssClass: 'btn-warning', action: function(dialogRef){ dialogRef.setClosable(false); } }, { label: 'Close the dialog', action: function(dialogRef){ dialogRef.close(); } }] });
關閉對話方塊的更多控制元件
預設情況下,當選擇 'closable' 設定為true,對話方塊可以通過這些方式關閉:點選在對話方塊中,按ESC鍵,點選對話方塊標題右側的關閉圖示。
如果你想讓你的對話方塊關閉時,對話方塊標題的關閉圖示被點選,可以設定的選項 'closeByBackdrop' and 'closeByKeyboard' 為 false.
BootstrapDialog.show({ message: 'Hi Apple!', message: 'You can not close this dialog by clicking outside and pressing ESC key.', closable: true, closeByBackdrop: false, closeByKeyboard: false, buttons: [{ label: 'Close the dialog', action: function(dialogRef){ dialogRef.close(); } }] });
Confirm
BootstrapDialog.confirm('Hi Apple, are you sure?');
Confirm with callback
BootstrapDialog.confirm('Hi Apple, are you sure?', function(result){ if(result) { alert('Yup.'); }else { alert('Nope.'); } });
Available options
Please note that all options described below are optional, but you will have a weird dialog if you don't even give it a message to display.
Most options can be set via init options or property setters.
Option | Possible values | Description |
---|---|---|
type | BootstrapDialog.TYPE_DEFAULT or 'type-default' BootstrapDialog.TYPE_INFO or 'type-info' BootstrapDialog.TYPE_PRIMARY or 'type-primary' (default) BootstrapDialog.TYPE_SUCCESS or 'type-success' BootstrapDialog.TYPE_WARNING or 'type-warning' BootstrapDialog.TYPE_DANGER or 'type-danger' |
Give your dialog a specific look, color scheme can be seen on Bootstrap's Button. |
size | BootstrapDialog.SIZE_NORMAL or 'size-normal' (default) BootstrapDialog.SIZE_WIDE or 'size-wide' BootstrapDialog.SIZE_LARGE or 'size-large' |
- |
cssClass | - | Additional css classes that will be added to your dialog. |
title | String or Object(html) | - |
message | String or Object(html) | - |
buttons | array | Examples:
|
id: optional, if id is set, you can use dialogInstance.getButton(id) to get the button later. icon: optional, if set, the specified icon will be added to the button. cssClass: optional, additional css class to be added to the button. autospin: optinal, if it's true, after clicked the button a spinning icon appears. action: optional, if provided, the callback will be invoked after the button is clicked, and the dialog instance will be passed to the callback function. |
||
closable | true | false | When set to true, you can close the dialog by:
|
spinicon | Icon class name, for example 'glyphicon glyphicon-check'. Default value is 'glyphicon glyphicon-asterisk'. |
Specify what icon to be used as the spinning icon when button's 'autospin' is set to true. |
data | Key-value object. For example {'id' : '100'} | Data to be bound to the dialog. |
onshow | function | If provided, it will be invoked when the dialog is popping up. |
onshown | function | If provided, it will be invoked when the dialog is popped up. |
onhide | function | If provided, it will be invoked when the dialog is popping down. |
onhidden | function | If provided, it will be invoked when the dialog is popped down. |
autodestroy | true (default) | false | When it's true, all modal stuff will be removed from the DOM tree after the dialog is popped down, set it to false if you need your dialog (same instance) pups up and down again and again. |
description | String | If provided, 'aria-describedby' attribute will be added to the dialog with the description string as its value. This can improve accessibility, as the description can be read by screen readers. |
nl2br | true | false | Automatically convert line breaking character to <br /> if it's set to true, everything keeps original if it's false. |
Available methods
Method | Description |
---|---|
open() | Open the dialog. Usage: dialogInstance.open() |
close() |
相關推薦bootstrap之BootstrapDialog模態彈框: <div class="modal fade"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <bu bootstrap之daterangepicker---漢化以及擴展組件 tro div time 事件 r.js 日期 功能 date 一、擴展的功能 1、初始化時,會自動創建一個select標簽; 2、當改變select值時,日期也會自動改變,並且會調用apply按鈕的click事件 3、點擊此處進行 bootstrap之Orientationsys mes sage nds dha param ack bject left Orientation 調整屏幕方向的操作。 package io.appium.android.bootstrap.handler; import and 重修課程day54(bootstrap之css樣式)mit tip erro context ups highlight tac esc boot 一 bootstrap的介紹 Bootstrap是將html,css和js的代碼打包好了,只管我們拿來調用。是基於jquery開發的。 使用BootCDN提供的免費CDN加速 重修課程day55(Bootstrap之Bootstrap組件)warn other thumbnail 選擇 膠囊 inverse con port nav-tab 一 文本居中 col-xx-offset-xx:水平居中 center-block:使用於不涉及float標簽的水平居中,也不涉及列的居中,讓哪裏居中就寫到哪裏,本質 bootstrap之CSS全局樣式ins 定義 添加 文本 必須 pad 多個 子類 內容 一、排版樣式(paiban) 1、標題標簽 <body style="padding:20px"> <h1>h1.bootstrap</h1><br/> Bootstrap之javascript插件---彈出框(模態框)Modalboot mis out strong 設置 cnblogs true -o 分享圖片 簡介: 彈出框是一個經常使用的組件,一般用於彈出提示信息,確認信息,表單內容。 完整結構分析(可以沒有頭部和底部): 代碼示例: <!-- 彈出框的頭部 --> ssm整合bootstrap之分頁java ssm pageHelper 分頁 bootstrap 分頁是我們經常會碰到的需求之一,今天我們就使用企業中很常用的mybatis分頁插件pageHelper來給大家做一個ssm整合bootstrap分頁的案例先看效果圖:一:建立數據庫student:學生表student年級表g bootstrap之data-*常用屬性ogg bpa -c div AS oot model ref role 【1】data-toggle:指以什麽事件類型觸發,常用的有 data-toggle="button" //按鈕事件 data-toggle="dropdown" //下拉菜單 da bootstrap之增刪改查ali odata .html 顯示 return style pagelist CA null 後臺使用spring boot和spring cloud等。前端使用bootstrap框架進行基本操作,項目采用前後端分離。 1、查詢 <!-- HTML中代碼 此中 Bootstrap之底層媒體查詢ner isp width box 20px direct gree child cti <style> @media only screen and (min-width:1024px ) { #box{ display: fl Bootstrap之柵格系統1、柵格系統(佈局) Bootstrap內建了一套響應式、移動裝置優先的流式柵格系統,隨著螢幕裝置或視口(viewport)尺寸的增加,系統會自動分為最多12列。 我在這裡是把Bootstrap中的柵格系統叫做佈局。它就是通過一系列的行(row)與列(column)的組合建立頁面佈局,然後你的內 Bootstrap之fileinput檔案上傳控制元件前言~ 前段時間做專案用到了bootstrap裡中的檔案上傳控制元件,對此特定寫這篇文章,講述一下bootstrap的檔案上傳空間的使用方法。 我們進入正題吧! 首先bootstrap是基於jquery的,因此要匯入 Bootstrap之初始Bootstrap個人總結1、什麼是Bootstrap? Bootstrap是由Twiter的Mark Otto和Jacob ThornTon 兩位設計師開發的。 Bootstrap是2011年8月在GitHub上釋出的開源產品(開發原始碼)。 Bootstrap是個用於快速開發Web應用程式和網站的前端 bootstrap之datetimepicker的使用1、引入檔案 除了引入基本的jquery和bootstrap的js、bootstrap的css外,還需要引入bootstrap-datetimepicker.min.js,還有就是bootstrap-datet bootstrap 之表單佈局文章來自:原始碼線上https://www.shengli.me/css/422.html 垂直表單: 效果圖: (2)內聯表單:它的所有元素是內聯的,向左對齊的,標籤 BootStrap之包涵下拉選單的輸入框用法: <div class="row col-md-5 text-center"> <div class="input-group"><!--保持內聯,消除邊框,類 BootStrap之navigation導航普通導航: <ul class="nav nav-tabs nav-justified"> <!-- class=“active”:表示選中當前tab頁,高亮顯示,通過 BootStrap之面板panel普通面板: <div class="col-md-6"> <div class="panel panel-default"> <div class="pane BootStrap之彈窗alert資訊彈窗: <div class="row"> <div class="col-md-4"> <div class="alert alert-info">資訊 |