-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Copy pathdocumentation.html
2232 lines (2139 loc) · 108 KB
/
documentation.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="Bootbox.js - alert, confirm, prompt, and flexible dialogs for the Bootstrap framework" />
<meta name="keywords" content="bootbox,Bootstrap,modal" />
<link rel="apple-touch-icon" sizes="180x180" href="./apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="32x32" href="./favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="./favicon-16x16.png" />
<link rel="manifest" href="./site.webmanifest" />
<title>Documentation — Bootbox.js — alert, confirm, prompt, and flexible dialogs for the Bootstrap framework</title>
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700|Bree+Serif&display=swap" rel="stylesheet" />
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<link rel="stylesheet" href="./assets/css/prism.css" />
<link rel="stylesheet" href="./assets/css/main.css" />
<link rel="stylesheet" href="./assets/css/fontawesome.css" />
</head>
<body>
<div class="page-wrapper">
<nav class="d-flex flex-row align-items-center p-2 border-bottom bg-white sticky-top">
<div class="">
<a id="toggle-sidebar" class="btn rounded-0 p-3" href="#">
<i class="fas fa-bars"></i>
</a>
</div>
<div class="flex-fill">
<nav aria-label="breadcrumb" class="align-items-center">
<a href="./" class="text-no-decoration"><b class="text-brand">Bootbox.js</b></a> — alert, confirm, prompt, and flexible dialogs for the Bootstrap framework
</nav>
</div>
<div class="text-right text-nowrap mr-2">
<nav class="nav nav-navbar">
<a class="nav-item nav-link border-left border-right" href="./getting-started.html">
Getting Started
</a>
<a class="nav-item nav-link border-right" href="./examples.html">
Examples
</a>
<a class="nav-item nav-link border-right" href="./documentation.html">
Docs
</a>
<a class="nav-item nav-link border-right" href="./faq.html">
FAQs
</a>
<div class="nav-item dropdown border-right">
<a class="nav-link dropdown-toggle" href="#" id="revisions" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
v6.0.0
</a>
<div class="dropdown-menu" aria-labelledby="revisions">
<a class="dropdown-item active" href="./documentation.html">v6.0.0</a>
<a class="dropdown-item" href="v5.x/documentation.html">v5.x</a>
<a class="dropdown-item" href="v4.x/documentation.html">v4.x</a>
<a class="dropdown-item" href="v3.x/documentation.html">v3.x</a>
</div>
</div>
<a class="nav-item nav-link text-dark border-right mr-3" href="https://github.com/makeusabrew/bootbox">
<i class="fab fa-github"></i>
GitHub
</a>
<div class="form-inline">
<a class="btn btn-brand" href="https://github.com/makeusabrew/bootbox/releases/download/v6.0.0/bootbox.zip" id="download-bootbox">
<i class="fas fa-download"></i>
Download
</a>
</div>
</nav>
</div>
</nav>
<main class="page-content">
<div class="container-fluid">
<div class="d-flex flex-row py-3 align-items-stretch">
<article class="main-content px-4 mx-auto">
<div class="main-content-inner">
<h2 id="intro" class="my-3">Documentation</h2>
<p class="lead">
Currently viewing documentation for version <b>6.0.0</b>. Other versions: <a href="./v4.x/documentation.html">4.x</a> · <a href="./v3.x/documentation.html">3.x</a>
</p>
<div class="bg-white rounded p-5">
<article class="topic">
<header class="topic-header">
<h2 id="alert" class="topic-anchor">Alert</h2>
<pre class="h5 py-3 px-4 mb-4 border bg-light"><code>bootbox.alert(<span class="text-primary">string|element</span> <b>message</b>, [<span class="text-info">function</span> <b>callback</b>]);</code></pre>
</header>
<div class="topic-content">
<p class="mb-2">
A simple alert dialog with a single button. Pressing the <kbd aria-label="escape">ESC</kbd> key or clicking
the close button (<i class="fas fa-times"></i>) dismisses the dialog.
</p>
<div class="topic-subsection">
<h3 id="alert-basic-usage" class="topic-subsection-header topic-anchor">Basic Usage</h3>
<div class="topic-subsection-content">
<p>
This is the simplest usage of Bootbox, requiring only the text of the message you wish to show.
</p>
<div class="bb-example bb-example-modal">
<pre class="language-js line-numbers"><code>bootbox.alert('Your message here…');</code></pre>
<figure>
<figcaption id="example-bb-1" class="topic-anchor">Example <b>bb.1</b></figcaption>
<div class="bb-modal-dialog">
<div class="bb-modal-content">
<div class="bb-modal-header border-0">
<h5 class="bb-modal-title"></h5>
<button class="bootbox-close-button close btn-close" type="button"></button>
</div>
<div class="bb-modal-body">
<div class="bootbox-body">Your message here…</div>
</div>
<div class="bb-modal-footer">
<button class="btn btn-primary" type="button">OK</button>
</div>
</div>
</div>
</figure>
</div>
<p>
If you have code that should not be evaluated until the user has dismissed the alert
(see <a href="#note-non-blocking">Bootbox Limitations</a> below), call it within the callback function:
</p>
<pre class="language-js line-numbers mb-4"><code>bootbox.alert('Your message here…', function(){
/* your callback code */
});</code></pre>
<h4 id="alert-formatted-text" class="topic-anchor">Formatted text</h4>
<p>Your message can also contain HTML. <sup><a href="#note-html"><i class="fas fa-exclamation-triangle text-danger"></i></a></sup></p>
<div class="bb-example bb-example-modal">
<pre class="language-js line-numbers"><code>bootbox.alert('Your message <b>here…</b>');</code></pre>
<figure>
<figcaption id="example-bb-2" class="topic-anchor">Example <b>bb.2</b></figcaption>
<div class="bb-modal-dialog">
<div class="bb-modal-content">
<div class="bb-modal-header border-0">
<h5 class="bb-modal-title"></h5>
<button class="bootbox-close-button close btn-close" type="button"></button>
</div>
<div class="bb-modal-body">
<div class="bootbox-body">Your message <b>here…</b></div>
</div>
<div class="bb-modal-footer">
<button class="btn btn-primary" type="button">OK</button>
</div>
</div>
</div>
</figure>
</div>
<p>You can also pass a reference to a jQuery-selected element. <sup><a href="#note-html"><i class="fas fa-exclamation-triangle text-danger"></i></a></sup></p>
<div class="bb-example bb-example-modal">
<pre class="language-html line-numbers"><code><div id="message-template">Your message <b>here…</b></div>
<script>
let template = $('#message-template');
bootbox.alert(template);
</script></code></pre>
<figure>
<figcaption id="example-bb-2b" class="topic-anchor">Example <b>bb.2b</b></figcaption>
<div class="bb-modal-dialog">
<div class="bb-modal-content">
<div class="bb-modal-header border-0">
<h5 class="bb-modal-title"></h5>
<button class="bootbox-close-button close btn-close" type="button"></button>
</div>
<div class="bb-modal-body">
<div class="bootbox-body">Your message <b>here…</b></div>
</div>
<div class="bb-modal-footer">
<button class="btn btn-primary" type="button">OK</button>
</div>
</div>
</div>
</figure>
</div>
</div>
</div>
<div class="topic-subsection">
<h3 id="alert-advanced-usage" class="topic-subsection-header topic-anchor">Advanced Usage</h3>
<div class="topic-subsection-content">
<pre class="h5 py-3 px-4 mb-4 border bg-light"><code>bootbox.alert(<span class="text-primary">object</span> <b>options</b>);</code></pre>
<p class="mb-2">
Alerts can be customized, using the <a href="#dialog-options">options described below</a>. Here's an example of
a small alert, using <samp>size</samp>:
</p>
<div class="bb-example bb-example-modal">
<pre class="language-js line-numbers"><code>bootbox.alert({
size: 'small',
title: 'Your Title',
message: 'Your message here…',
callback: function() { /* your callback code */ }
});</code></pre>
<figure>
<figcaption id="example-bb-3" class="topic-anchor">Example <b>bb.3</b></figcaption>
<div class="bb-modal-dialog bb-modal-sm">
<div class="bb-modal-content">
<div class="bb-modal-header">
<h5 class="bb-modal-title">Your Title</h5>
<button class="bootbox-close-button close btn-close" type="button"></button>
</div>
<div class="bb-modal-body">
<div class="bootbox-body">Your message here…</div>
</div>
<div class="bb-modal-footer">
<button class="btn btn-primary" type="button">OK</button>
</div>
</div>
</div>
</figure>
</div>
<p>
<b>Requires Bootstrap 3.1.0 or newer</b>.
</p>
</div>
</div>
</div>
</article>
<hr class="section-divider" />
<article class="topic">
<header class="topic-header">
<h2 id="confirm" class="topic-anchor">Confirm</h2>
<pre class="h5 py-3 px-4 mb-2 bg-light border"><code>bootbox.confirm(<span class="text-primary">string|element</span> <b>message</b>, <span class="text-info">function</span> <b>callback</b>);</code></pre>
</header>
<div class="topic-content">
<p class="mb-2">
A confirm dialog with a cancel and a confirm button. Pressing the <kbd>ESC</kbd> key or clicking close (<i class="fas fa-times"></i>) dismisses
the dialog and invokes the callback as if the user had clicked the Cancel button.
</p>
<p class="bs-callout bs-callout-danger mb-4">
<i class="fas fa-exclamation-triangle"></i> Confirm dialogs require a callback function.
</p>
<div class="topic-subsection">
<h3 id="confirm-basic-usage" class="topic-subsection-header topic-anchor">Basic Usage</h3>
<div class="topic-subsection-content">
<p>
The simplest method of using the <samp>bootbox.confirm()</samp> dialog requires the text of the message you wish
to show and a callback to handle the user's selection. The callback function is passed a value of <samp>true</samp>
or <samp>false</samp>, depending on which button the user pressed.
</p>
<div class="bb-example bb-example-modal">
<pre class="language-js line-numbers"><code>bootbox.confirm('Are you sure?', function(result){
/* your callback code */
});</code></pre>
<figure>
<figcaption id="example-bb-4" class="topic-anchor">Example <b>bb.4</b></figcaption>
<div class="bb-modal-dialog">
<div class="bb-modal-content">
<div class="bb-modal-header border-0">
<h5 class="bb-modal-title"></h5>
<button class="bootbox-close-button close btn-close" type="button"></button>
</div>
<div class="bb-modal-body">
<div class="bootbox-body">Are you sure?</div>
</div>
<div class="bb-modal-footer">
<button class="btn btn-secondary" type="button">Cancel</button>
<button class="btn btn-primary" type="button">OK</button>
</div>
</div>
</div>
</figure>
</div>
<div class="bs-callout bs-callout-danger mb-4">
<h5 id="confirm-callout-callback" class="topic-anchor callout-heading"><i class="fas fa-exclamation-triangle"></i> Please note:</h5>
<p>
<b>All</b> Bootstrap modals, unlike native alerts, confirms, or prompts, are <a href="#note-non-blocking"><b>non-blocking</b></a>.
Keep that in mind when using the <samp>bootbox.confirm()</samp> dialog, as it is <b>not</b> a drop-in replacement for native confirm dialogs.
Any code that depends on the user's selection <b>must</b> be placed in the callback function.
</p>
</div>
</div>
</div>
<div class="topic-subsection">
<h3 id="confirm-advanced-usage" class="topic-subsection-header topic-anchor">Advanced Usage</h3>
<div class="topic-subsection-content">
<pre class="h5 py-3 px-4 mb-4 bg-light border"><code>bootbox.confirm(<span class="text-primary">object</span> <b>options</b>);</code></pre>
<p class="mb-2">
Confirm dialogs can be customized, using the <a href="#dialog-options">options described below</a>. Here's an example of a small
confirm, using <samp>size</samp>:
</p>
<div class="bb-example bb-example-modal">
<pre class="language-js line-numbers"><code>bootbox.confirm({
size: 'small',
message: 'Are you sure?',
callback: function(result){ /* result is a boolean; true = OK, false = Cancel*/ }
});</code></pre>
<figure>
<figcaption id="example-bb-5" class="topic-anchor">Example <b>bb.5</b></figcaption>
<div class="bb-modal-dialog bb-modal-sm">
<div class="bb-modal-content">
<div class="bb-modal-header border-0">
<h5 class="bb-modal-title"></h5>
<button class="bootbox-close-button close btn-close" type="button"></button>
</div>
<div class="bb-modal-body">
<div class="bootbox-body">Are you sure?</div>
</div>
<div class="bb-modal-footer">
<button class="btn btn-secondary" type="button">Cancel</button>
<button class="btn btn-primary" type="button">OK</button>
</div>
</div>
</div>
</figure>
</div>
<p>
<b>Requires Bootstrap 3.1.0 or newer</b>.
</p>
</div>
</div>
</div>
</article>
<hr class="section-divider" />
<article class="topic">
<header class="topic-header">
<h2 id="prompt" class="topic-anchor">Prompt</h2>
<pre class="h5 py-3 px-4 mb-2 border bg-light"><code>bootbox.prompt(<span class="text-primary">string|element</span> <b>title</b>, <span class="text-info">function</span> <b>callback</b>);</code></pre>
</header>
<div class="topic-content">
<p class="mb-2">
A dialog which prompts for user input. Pressing the <kbd>ESC</kbd> key or clicking close (<i class="fas fa-times"></i>) dismisses the dialog
and invokes the callback as if the user had clicked the Cancel button.
</p>
<p class="bs-callout bs-callout-danger mb-4">
<i class="fas fa-exclamation-triangle"></i> Prompt dialogs require a callback function.
</p>
<div class="topic-subsection">
<h3 id="prompt-basic-usage" class="topic-subsection-header topic-anchor">Basic Usage</h3>
<div class="topic-subsection-content">
<p>
The simplest usage of the <samp>bootbox.prompt()</samp> dialog requires the text of the message you wish to show
and a callback to handle the user's input. The value entered will be <samp>null</samp> if the user cancelled
or dismissed the dialog; otherwise it is passed the value of the text input.
</p>
<div class="bb-example bb-example-modal">
<pre class="language-js line-numbers"><code>bootbox.prompt('What is your name?', function(result){
/* your callback code */
});</code></pre>
<figure>
<figcaption id="example-bb-6" class="topic-anchor">Example <b>bb.6</b></figcaption>
<div class="bb-modal-dialog">
<div class="bb-modal-content">
<div class="bb-modal-header">
<h5 class="bb-modal-title" style="margin: 0; padding: 0;">What is your name?</h5>
<button class="bootbox-close-button close btn-close" type="button"></button>
</div>
<div class="bb-modal-body">
<div class="bootbox-body">
<form class="bootbox-form">
<input type="text" autocomplete="off" class="bootbox-input bootbox-input-text form-control" />
</form>
</div>
</div>
<div class="bb-modal-footer">
<button class="btn btn-secondary" type="button">Cancel</button>
<button class="btn btn-primary" type="button">OK</button>
</div>
</div>
</div>
</figure>
</div>
<div class="bs-callout bs-callout-danger">
<h5 id="prompt-callout-callback" class="topic-anchor callout-heading"><i class="fas fa-exclamation-triangle"></i> Please note:</h5>
<p>
<b>All</b> Bootstrap modals, unlike native alerts, confirms, or prompts, are <a href="#note-non-blocking"><b>non-blocking</b></a>.
Keep that in mind when using the <samp>bootbox.prompt()</samp> dialog, as it is <b>not</b> a drop-in replacement for native prompt dialogs.
Any code that depends on the user's input <b>must</b> be placed in the callback function.
</p>
</div>
</div>
</div>
<div class="topic-subsection">
<h3 id="prompt-advanced-usage" class="topic-subsection-header topic-anchor">Advanced Usage</h3>
<div class="topic-subsection-content">
<pre class="h5 py-3 px-4 mb-4 border bg-light"><code>bootbox.prompt(<span class="text-primary">object</span> <b>options</b>);</code></pre>
<p class="mb-2">
Prompt dialogs can also be customized, using the <a href="#prompt-options">options described below</a>. Here's an example of a
small prompt, using <samp>size</samp>:
</p>
<div class="bb-example bb-example-modal">
<pre class="language-js line-numbers"><code>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 */
}
});</code></pre>
<figure>
<figcaption id="example-bb-7" class="topic-anchor">Example <b>bb.7</b></figcaption>
<div class="bb-modal-dialog bb-modal-sm">
<div class="bb-modal-content">
<div class="bb-modal-header">
<h5 class="bb-modal-title" style="margin: 0; padding: 0;">What is your name?</h5>
<button class="bootbox-close-button close btn-close" type="button"></button>
</div>
<div class="bb-modal-body">
<div class="bootbox-body">
<form class="bootbox-form">
<input type="text" autocomplete="off" class="bootbox-input bootbox-input-text form-control" />
</form>
</div>
</div>
<div class="bb-modal-footer">
<button class="btn btn-secondary" type="button">Cancel</button>
<button class="btn btn-primary" type="button">OK</button>
</div>
</div>
</div>
</figure>
</div>
<p>
<b>Requires Bootstrap 3.1.0 or newer</b>.
</p>
<div class="bs-callout bs-callout-info mb-4">
<h5 id="prompt-callout-title" class="topic-anchor callout-heading">
<i class="fas fa-info-circle"></i> Please note:
</h5>
<p>
Prompt <b>requires</b> the <samp>title</samp> option (when using the options object). You may use the <samp>message</samp>
option, but the prompt result will <b>not</b> include any form values from your message.
</p>
</div>
</div>
</div>
</div>
</article>
<hr class="section-divider" />
<article class="topic">
<div class="topic-content">
<h3 id="prompt-options" class="topic-subsection-header topic-anchor">Prompt Dialog Options</h3>
<div class="topic-subsection-content">
<p>
Prompt dialogs are (by default) single-line text inputs. You can modify the type of prompt Bootbox generates using the prompt-only
options below.
</p>
<dl class="options-list">
<dt id="prompt-option-value" class="topic-anchor topic-subsection-header h4">value</dt>
<dd class="topic-subsection-content">
<p class="mb-1">
<span class="meta-info">Type:</span>
<span class="meta-types"><code>String</code><code>Number</code><code>Array</code></span>
</p>
<p class="mb-3">
<span class="meta-info">Default:</span>
<code>null</code>
</p>
<p>
You can set the initial value of the prompt using the <samp>value</samp> option.
</p>
<p>
<i class="fas fa-info-circle text-info"></i>
To pre-select more than one value (when using the checkbox or multiple select type), use an array
for the <samp>value</samp> option. Note that the type of each item should match the type
from <samp>inputOptions</samp>.
</p>
</dd>
<dt id="prompt-option-input-type" class="topic-anchor topic-subsection-header h4">inputType</dt>
<dd class="topic-subsection-content">
<p class="mb-1">
<span class="meta-info">Type:</span>
<span class="meta-types"><code>String</code></span>
</p>
<p class="mb-3">
<span class="meta-info">Default:</span>
<code>text</code>
</p>
<p>
Changes the type of input generated for the prompt dialog.
</p>
<p>
<i class="fas fa-info-circle text-info"></i>
To pre-select more than one value (when using the checkbox or multiple select type), use an array
for the <samp>value</samp> option. Note that the type of each item should match the type
from <samp>inputOptions</samp>.
</p>
<p>
Valid values, with their class selectors:
</p>
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>Class</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>text</code> (default)</td>
<td><code>bootbox-input-text</code></td>
</tr>
<tr>
<td><code>password</code></td>
<td><code>bootbox-input-password</code></td>
</tr>
<tr>
<td><code>textarea</code></td>
<td><code>bootbox-input-textarea</code></td>
</tr>
<tr>
<td><code>email</code></td>
<td><code>bootbox-input-email</code></td>
</tr>
<tr>
<td><code>select</code></td>
<td><code>bootbox-input-select</code></td>
</tr>
<tr>
<td><code>checkbox</code></td>
<td><code>bootbox-input-checkbox</code></td>
</tr>
<tr>
<td><code>radio</code></td>
<td><code>bootbox-input-radio</code></td>
</tr>
<tr>
<td><code>date</code></td>
<td><code>bootbox-input-date</code></td>
</tr>
<tr>
<td><code>time</code></td>
<td><code>bootbox-input-time</code></td>
</tr>
<tr>
<td><code>number</code></td>
<td><code>bootbox-input-number</code></td>
</tr>
<tr>
<td><code>range</code></td>
<td><code>bootbox-input-range</code></td>
</tr>
</tbody>
</table>
<p>
Additionally, checkbox and radiobuttons are wrapped in a parent element, <samp>bootbox-checkbox-list</samp>
and <samp>bootbox-radiobutton-list</samp>, respectively.
</p>
<p>
<samp>email</samp>, <samp>date</samp>, <samp>time</samp>, <samp>number</samp>, and <samp>range</samp>
all require browser support to function properly. You may want to consult <a href="https://caniuse.com">caniuse.com</a>
to determine if your target browsers support the input types you are intending to use.
</p>
<h5 id="note-date-time-input">Date input type and browser support</h5>
<p>
At the time this is written, every major browser which supports the <samp>date</samp> input type will only
accept date values in the ISO 8601 format, which (for a short date) is <samp>YYYY-MM-DD</samp>, where
</p>
<pre>YYYY = four-digit year
MM = two-digit month (01 = January, etc.)
DD = two-digit day of month (01 through 31)
</pre>
<p>
See <a href="https://en.wikipedia.org/wiki/ISO_8601">https://en.wikipedia.org/wiki/ISO_8601</a>
</p>
<h5 id="note-range-min-max">Range input and default value</h5>
<p>
Please note that, when using the <samp>range</samp> input type, the default <samp>min</samp> value
is <samp>0</samp> and the default <samp>max</samp> value is <samp>100</samp> (see
<a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/range#Specifying_the_minimum_and_maximum">MDN</a>).
If you attempt to set the default value of the input to something less than your min value or greater than your max value,
the input will default to the respective value.
</p>
</dd>
<dt id="prompt-option-input-options" class="topic-anchor topic-subsection-header h4">inputOptions</dt>
<dd class="topic-subsection-content">
<p class="mb-1">
<span class="meta-info">Type:</span>
<span class="meta-types"><code>Array</code></span>
</p>
<p class="mb-3">
<span class="meta-info">Default:</span>
<code>null</code>
</p>
<p>
If you specify <samp>select</samp>, <samp>checkbox</samp>, or <samp>radio</samp> as the
input type, you must also supply an array of valid values in the format of:
</p>
<pre class="language-js line-numbers"><code>{
text: '',
value: '',
group: ''
}</code></pre>
<p>
<samp>group</samp> is an optional property for populating the <samp><select></samp>;
if specified, <samp><optgroup></samp> elements will be generated for each group
value found in the <samp>inputOptions</samp> array.
</p>
</dd>
<dt id="prompt-option-input-min-max" class="topic-anchor topic-subsection-header h4">min, max</dt>
<dd class="topic-subsection-content">
<p class="mb-1">
<span class="meta-info">Type:</span>
<span class="meta-types"><code>String</code><code>Number</code><code>Date String</code><code>Time string</code></span>
</p>
<p class="mb-1">
<span class="meta-info">Default:</span>
<code>null</code>
</p>
<p class="mb-3">
<span class="meta-info">Types:</span>
<span>
<code>date</code>,
<code>time</code>,
<code>number</code>,
<code>range</code>
</span>
</p>
<p>
The <samp>min</samp> or <samp>max</samp> value for the <samp><input></samp> element.
</p>
<p>
For <samp>range</samp> and <samp>number</samp>, min/max must be
a numeric value.
</p>
<p>
For <samp>time</samp>, min/max must a valid partial time value,
in the form of <samp>HH:MM:SS</samp>, where
</p>
<pre>HH = any zero-padded value between <samp>00</samp> and <samp>23</samp>
MM = any zero-padded value between <samp>00</samp> and <samp>59</samp>
SS = any zero-padded value between <samp>00</samp> and <samp>59</samp>
</pre>
<p>
For <samp>date</samp>, min/max must a date value in the form
of <samp>YYYY-MM-DD</samp>, where
</p>
<pre>YYYY = four-digit year
MM = two-digit month (01 = January, etc.)
DD = two-digit day of month (01 through 31)
</pre>
<p>
See the MDN article for
<a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-min">min</a> or
<a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-max">max</a> for more information.
</p>
<h5 id="note-number-min-max">Number input and min/max values</h5>
<p>
When using the <samp>number</samp> input type, note that a value may be manually entered which is less than your min or greater than
your max (<a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number#Specifying_minimum_and_maximum_values">MDN</a>).
The input will, however, report that it is invalid, which can be used in conjunction with the <a href="prompt-option-required">required</a>
option to prevent the value from being accepted.
</p>
</dd>
<dt id="prompt-option-input-step" class="topic-anchor topic-subsection-header h4">step</dt>
<dd class="topic-subsection-content">
<p class="mb-1">
<span class="meta-info">Type:</span>
<span class="meta-types"><code>String</code><code>Number</code></span>
</p>
<p class="mb-1">
<span class="meta-info">Default:</span>
<code>null</code>
</p>
<p class="mb-3">
<span class="meta-info">Types:</span>
<span>
<code>time</code>,
<code>number</code>,
<code>range</code>
</span>
</p>
<p>
The <samp>step</samp> value for the <samp><input></samp> element.
</p>
<p>
Can be the string value <samp>any</samp> (the browser default), or a positive, non-zero
numeric value. See
<a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-step">the MDN article for <samp><input></samp></a>
for more information.
</p>
<p>
The default <samp>step</samp> value for <samp>number</samp> inputs is <samp>1</samp>
(<a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number#attr-step">MDN</a>).
</p>
<div class="bs-callout bs-callout-warning">
<p>
<i class="fas fa-exclamation-triangle"></i> <b>Warning:</b> For most browsers, date inputs are buggy in their implementation of <samp>step</samp>,
so this attribute would likely have no effect. Therefore, we don't set the step attribute
for date inputs.
</p>
<p>
See <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date#Setting_maximum_and_minimum_dates">the MDN article</a>
for more information.
</p>
</div>
</dd>
<dt id="prompt-option-input-maxlength" class="topic-anchor topic-subsection-header h4">maxlength</dt>
<dd class="topic-subsection-content">
<p class="mb-1">
<span class="meta-info">Type:</span>
<span class="meta-types"><code>Number</code></span>
</p>
<p class="mb-1">
<span class="meta-info">Default:</span>
<code>null</code>
</p>
<p class="mb-3">
<span class="meta-info">Types:</span>
<span>
<code>text</code>,
<code>textarea</code>,
<code>email</code>,
<code>password</code>
</span>
</p>
<p>
Set the <samp>maxlength</samp> option to limit the number of characters entered into a
text-based input. Must be a positive, non-zero numeric value.
</p>
</dd>
<dt id="prompt-option-input-pattern" class="topic-anchor topic-subsection-header h4">pattern</dt>
<dd class="topic-subsection-content">
<p class="mb-1">
<span class="meta-info">Type:</span>
<span class="meta-types"><code>String</code></span>
</p>
<p class="mb-1">
<span class="meta-info">Default:</span>
<code>null</code>
</p>
<p class="mb-3">
<span class="meta-info">Types:</span>
<span>
All, except
<code>select</code>,
<code>radio</code>,
<code>checkbox</code>
</span>
</p>
<p>
Set the <samp>pattern</samp> option to require the input value to follow a specific format.
If <samp>pattern</samp> is set and a value has been entered by your user, the prompt will not
close if the input value fails pattern validation.
</p>
<p>
Can be added as a fallback for <samp>email</samp>, <samp>time</samp>, <samp>date</samp>, <samp>number</samp>
or <samp>range</samp> inputs where native browser support for those types is lacking.
</p>
</dd>
<dt id="prompt-option-input-placeholder" class="topic-anchor topic-subsection-header h4">placeholder</dt>
<dd class="topic-subsection-content">
<p class="mb-1">
<span class="meta-info">Type:</span>
<span class="meta-types"><code>String</code></span>
</p>
<p class="mb-1">
<span class="meta-info">Default:</span>
<code>null</code>
</p>
<p class="mb-3">
<span class="meta-info">Types:</span>
<span>
All <sup class="text-muted">*</i>
</span>
</p>
<p>
Set the <samp>placeholder</samp> option to provide a small amount of "helper" text
within a text-based input.
</p>
<p>
There is no real limit on the amount of text you may use for your placeholder, but
keep in mind that the placeholder disappears when the input has focus (depending on
the browser) or has a value. Use the <samp>message</samp> option to provide help text
which you want to always be visible or that is important.
</p>
<p>
<b>*</b> If specified for <samp>time</samp>, <samp>date</samp>, <samp>number</samp>, or <samp>range</samp> inputs,
your users will normally only see the placeholder where native browser support for those types is lacking. We also
will set the placeholder attribute on a <samp>select</samp>, although that's not a valid/supported attribute.
</p>
</dd>
<dt id="prompt-option-input-required" class="topic-anchor topic-subsection-header h4">required</dt>
<dd class="topic-subsection-content">
<p class="mb-1">
<span class="meta-info">Type:</span>
<span class="meta-types"><code>Boolean</code></span>
</p>
<p class="mb-3">
<span class="meta-info">Default:</span>
<code>null</code>
</p>
<p>
Set the <samp>required</samp> option to <samp>true</samp> to require an input value.
When <samp>true</samp>, the prompt will not close if the input value is <samp>null</samp>,
an empty string, or fails the input type's built-in validation constraints.
</p>
<p>
<i class="fas fa-info-circle text-info"></i>
If used with the <samp>checkbox</samp> inputType, each checkbox must be checked for the prompt to be valid.
</p>
</dd>
<dt id="prompt-option-input-multiple" class="topic-anchor topic-subsection-header h4">multiple</dt>
<dd class="topic-subsection-content">
<p class="mb-1">
<span class="meta-info">Type:</span>
<span class="meta-types"><code>Boolean</code></span>
</p>
<p class="mb-1">
<span class="meta-info">Default:</span>
<code>null</code>
</p>
<p class="mb-3">
<span class="meta-info">Types:</span>
<code>select</code>
</p>
<p>
Set the <samp>multiple</samp> option to <samp>true</samp> to allow users to
select more than one option when using the <samp>select</samp> input type.
</p>
<p>
<i class="fas fa-info-circle text-info"></i>
To pre-select more than one value, use an array for the <samp>value</samp> option. Note that the type
of each item should match the type from <samp>inputOptions</samp>.
</p>
</dd>
<dt id="prompt-option-input-rows" class="topic-anchor topic-subsection-header h4">rows</dt>
<dd class="topic-subsection-content">
<p class="mb-1">
<span class="meta-info">Type:</span>
<span class="meta-types"><code>Number</code></span>
</p>
<p class="mb-1">
<span class="meta-info">Default:</span>
<code>null</code>
</p>
<p class="mb-3">
<span class="meta-info">Types:</span>
<code>textarea</code>
</p>
<p>
Set the <samp>rows</samp> option to a non-zero number to set the <samp>rows</samp> attribute
when using the <samp>textarea</samp> input type. If omitted, the <samp>rows</samp> attribute is
not set and the textarea will render with the browser's default number of rows.
</p>
</dd>
</dl>
<p>
Please see the <a href="./examples.html#prompt">Examples page</a> for more examples of prompt
dialogs.
</p>
</div>
</div>
</article>
<hr class="section-divider" />
<article class="topic">
<header class="topic-header">
<h2 id="dialog" class="topic-anchor">Custom Dialog</h2>
<pre class="h5 py-3 px-4 mb-2 bg-light border"><code>bootbox.dialog(<span class="text-primary">object</span> <b>options</b>);</code></pre>
</header>
<div class="topic-content">
<p class="mb-2">
A completely customisable dialog method which takes a single argument - an options object.
</p>
<div class="topic-subsection">
<h3 id="dialog-note" class="topic-subsection-header topic-anchor d-none">Note: onEscape</h3>
<div class="topic-subsection-content">
<p>
<b>Custom dialogs do not close automatically when the <kbd>ESC</kbd> key is pressed;</b> you must implement
this behavior yourself using the <a href="#option-onEscape"><samp>onEscape</samp></a> option.
</p>
</div>
</div>
<div class="topic-subsection">
<h3 id="dialog-basic-usage" class="topic-subsection-header topic-anchor">Basic Usage</h3>
<div class="topic-subsection-content">
<p>
The minimum required to create a custom dialog is the <samp>message</samp> option.
</p>
<p>
Here's an example using <samp>message</samp> and <samp>closeButton: false</samp>, which will create
a non-dismissable dialog (useful as a "loading" overlay).
</p>
<div class="bb-example bb-example-modal">
<pre class="language-js line-numbers"><code>bootbox.dialog({
message: '<div class="text-center"><i class="fas fa-spin fa-spinner"></i> Loading...</div>',
closeButton: false
});</code></pre>
<figure>
<figcaption id="example-bb-8" class="topic-anchor">Example <b>bb.8</b></figcaption>
<div class="bb-modal-dialog">
<div class="bb-modal-content">
<div class="bb-modal-body">
<div class="bootbox-body">
<div class="text-center"><i class="fas fa-spin fa-spinner"></i> Loading...</div>
</div>
</div>
</div>
</div>
</figure>
</div>
</div>
</div>
<div class="topic-subsection">
<h3 id="dialog-advanced-usage" class="topic-subsection-header topic-anchor">Advanced Usage</h3>
<div class="topic-subsection-content">
<p>
As noted above, the only required option for a custom dialog is <samp>message</samp>. Also,
<b>custom dialogs do not utilize a global callback</b>;
each button you add should have it's own callback function. Here's an example with many of
the options utilized:
</p>
<div class="bb-example bb-example-modal bb-example-modal-advanced">
<pre class="language-js line-numbers"><code>bootbox.dialog({
title: 'Custom Dialog Example',
message: '<p>This dialog demonstrates many of the options available when using the Bootbox library</p>',
size: 'large',
onEscape: true,
backdrop: true,
buttons: {
fee: {
label: 'Fee',
className: 'btn-primary',
callback: function(){
}
},
fie: {
label: 'Fie',
className: 'btn-info',
callback: function(){
}
},
foe: {
label: 'Foe',
className: 'btn-success',
callback: function(){
}
},
fum: {
label: 'Fum',
className: 'btn-danger',
callback: function(){
}
}
}
});</code></pre>
<figure>
<figcaption id="example-bb-9" class="topic-anchor">Example <b>bb.9</b></figcaption>
<div class="bb-modal-dialog bb-modal-lg">
<div class="bb-modal-content">
<div class="bb-modal-header">
<h5 class="bb-modal-title">Custom Dialog Example</h5>
<button class="bootbox-close-button close btn-close" type="button"></button>
</div>
<div class="bb-modal-body">
<div class="bootbox-body">
<p>This dialog demonstrates many of the options available when using the Bootbox library</p>
</div>
</div>
<div class="bb-modal-footer">
<button type="button" class="btn btn-primary">Fee</button>
<button type="button" class="btn btn-info">Fie</button>
<button type="button" class="btn btn-success">Foe</button>
<button type="button" class="btn btn-danger">Fum</button>
</div>
</div>
</div>
</figure>
</div>
<p>
Please see the <a href="./examples.html#dialog">Examples page</a> for more examples of custom
dialogs.
</p>
</div>
</div>
</div>