Use of Bootbox.js in bootstrap framework

Use of Bootbox.js in bootstrap framework

Hi everyone in this article I’m explaining about Bootbox.js file of bootstrap for model dialog.

Description:

I’ve been using twitter's bootstrap framework for a number of sites builds recently, mainly because it gets me from black-and-white markup to vaguely-presentable websites in a very small amount of time.

If we talk about the latest version 1.3 of JavaScript, we know that some JavaScript plugins have been introduced in it to complement the array of stylistic elements already provided - specifically the dialog box or modal Code to implement.

A recent project I've been working on required extensive use of JavaScript's native alert and confirm dialogs, but their crude behavior and wildly varying appearance between browsers is always somewhat dissatisfying, so I wanted to combine their basic functionality with bootstrap's slick-looking dialog boxes. Enter bootbox.js - alert () and confirm () like behavior using twitter's modal dialog boxes.

Download bootstrap package:

<link href='~/Content/bootstrap/css/bootstrap.min.css' rel='stylesheet' />

<script src='~/Scripts/jquery-2.1.1.min.js'></script>

<script src='~/Scripts/bootstrap/js/bootstrap.min.js'></script>

Dialog using Twitter Bootstrap:

You may be wondering why a few wrapper methods around bootstrap's built-in dialog capabilities are either necessary or desirable. To begin to answer that, let's look at the code required to show a simple alert style dialog programmatically using bootstrap:

'x_x_str'>'x_x_tag'>'x_x_tag'><a href='x_x_str'>'x_x_str'>'x_x_str'>'#' data-bb='x_x_str'>'x_x_str'>'x_x_str'>'alert' class='x_x_str'>'x_x_str'>'x_x_str'>'bb-trigger btn btn-info' id='x_x_str'>'x_x_str'>'x_x_str'>'launchmodel'>Launch Model'x_x_str'>'x_x_tag'>'x_x_tag'></a>

'x_x_str'>'x_x_tag'>'x_x_tag'><div id='x_x_str'>'x_x_str'>'x_x_str'>'myModal' class='x_x_str'>'x_x_str'>'x_x_str'>'modal fade'>
  'x_x_str'>'x_x_tag'>'x_x_tag'><div class='x_x_str'>'x_x_str'>'x_x_str'>'modal-dialog'>
    'x_x_str'>'x_x_tag'>'x_x_tag'><div class='x_x_str'>'x_x_str'>'x_x_str'>'modal-content'>
      'x_x_str'>'x_x_tag'>'x_x_tag'><div class='x_x_str'>'x_x_str'>'x_x_str'>'modal-body'>
        'x_x_str'>'x_x_tag'>'x_x_tag'><button type='x_x_str'>'x_x_str'>'x_x_str'>'button' class='x_x_str'>'x_x_str'>'x_x_str'>'close' data-dismiss='x_x_str'>'x_x_str'>'x_x_str'>'modal'>&times;'x_x_str'>'x_x_tag'>'x_x_tag'></button>
        Hello world!
      'x_x_str'>'x_x_tag'>'x_x_tag'></div>
      'x_x_str'>'x_x_tag'>'x_x_tag'><div class='x_x_str'>'x_x_str'>'x_x_str'>'modal-footer'>'x_x_str'>'x_x_tag'>'x_x_tag'><button type='x_x_str'>'x_x_str'>'x_x_str'>'button' class='x_x_str'>'x_x_str'>'x_x_str'>'btn btn-primary'>OK'x_x_str'>'x_x_tag'>'x_x_tag'></button>'x_x_str'>'x_x_tag'>'x_x_tag'></div>
    'x_x_str'>'x_x_tag'>'x_x_tag'></div>
  'x_x_str'>'x_x_tag'>'x_x_tag'></div>
'x_x_str'>'x_x_tag'>'x_x_tag'></div>

$'x_x_str'>'x_x_bracket'>'x_x_bracket'>(document'x_x_str'>'x_x_bracket'>'x_x_bracket'>)'x_x_str'>'x_x_selector'>'x_x_selector'>.ready'x_x_str'>'x_x_bracket'>'x_x_bracket'>('x_x_keyword'>function 'x_x_str'>'x_x_bracket'>'x_x_bracket'>('x_x_str'>'x_x_bracket'>'x_x_bracket'>) 'x_x_str'>'x_x_bracket'>'x_x_bracket'>{
        $'x_x_str'>'x_x_bracket'>'x_x_bracket'>('x_x_str'>'x_x_str'>'x_x_str'>'#launchmodel''x_x_str'>'x_x_bracket'>'x_x_bracket'>)'x_x_str'>'x_x_selector'>'x_x_selector'>.click'x_x_str'>'x_x_bracket'>'x_x_bracket'>('x_x_keyword'>function 'x_x_str'>'x_x_bracket'>'x_x_bracket'>('x_x_str'>'x_x_bracket'>'x_x_bracket'>) 'x_x_str'>'x_x_bracket'>'x_x_bracket'>{
            $'x_x_str'>'x_x_bracket'>'x_x_bracket'>('x_x_str'>'x_x_str'>'x_x_str'>'#myModal''x_x_str'>'x_x_bracket'>'x_x_bracket'>)'x_x_str'>'x_x_selector'>'x_x_selector'>.modal'x_x_str'>'x_x_bracket'>'x_x_bracket'>('x_x_str'>'x_x_bracket'>'x_x_bracket'>{
                'x_x_str'>'x_x_str'>'x_x_str'>'backdrop': 'x_x_str'>'x_x_str'>'x_x_str'>'static',
                'x_x_str'>'x_x_str'>'x_x_str'>'keyboard': true,
                'x_x_str'>'x_x_str'>'x_x_str'>'show': true
            'x_x_str'>'x_x_bracket'>'x_x_bracket'>}'x_x_str'>'x_x_bracket'>'x_x_bracket'>);
        'x_x_str'>'x_x_bracket'>'x_x_bracket'>}'x_x_str'>'x_x_bracket'>'x_x_bracket'>);
    'x_x_str'>'x_x_bracket'>'x_x_bracket'>}'x_x_str'>'x_x_bracket'>'x_x_bracket'>);
'x_x_str'>'x_x_the-num'>
'x_x_the-num'>

Dynamically creating the model popup for all kinds of alerts using Bootbox.js 

Bootbox.js is a jQuery library that enables us to generate the model popup dynamically, this reduces the use of writing the HTML code for model popup and javascript for every element, again and again, it acts as a general way to create all type of model popup dynamically.

Download Bootbox.js from here: http://bootboxjs.com/ 

Example:

Open model popup using Bootbox.js 

'x_x_str'>'x_x_tag'>'x_x_tag'><link href='x_x_str'>'x_x_str'>'x_x_str'>'~/Content/bootstrap/css/bootstrap.min.css' rel='x_x_str'>'x_x_str'>'x_x_str'>'stylesheet' />

'x_x_str'>'x_x_tag'>'x_x_tag'><style>
    'x_x_str'>'x_x_selector'>'x_x_selector'>.bb-alert 'x_x_str'>'x_x_bracket'>'x_x_bracket'>{
        'x_x_attribute'>position: fixed;
        'x_x_attribute'>top: 'x_x_num'>0;
        'x_x_attribute'>right: 'x_x_num'>0;
        'x_x_attribute'>font-size: 'x_x_num'>1'x_x_str'>'x_x_selector'>.'x_x_num'>2em;
        'x_x_attribute'>padding: 'x_x_num'>1em 'x_x_num'>1'x_x_str'>'x_x_selector'>.'x_x_num'>3em;
        'x_x_attribute'>z-index: 'x_x_num'>2000;
    'x_x_str'>'x_x_bracket'>'x_x_bracket'>}
'x_x_str'>'x_x_tag'>'x_x_tag'></style>
'x_x_str'>'x_x_tag'>'x_x_tag'><div class='x_x_str'>'x_x_str'>'x_x_str'>'clearfix'>&nbsp;'x_x_str'>'x_x_tag'>'x_x_tag'></div>
'x_x_str'>'x_x_tag'>'x_x_tag'><div class='x_x_str'>'x_x_str'>'x_x_str'>'clearfix'>&nbsp;'x_x_str'>'x_x_tag'>'x_x_tag'></div>
'x_x_str'>'x_x_tag'>'x_x_tag'><div class='x_x_str'>'x_x_str'>'x_x_str'>'container'>
    'x_x_str'>'x_x_tag'>'x_x_tag'><div class='x_x_str'>'x_x_str'>'x_x_str'>'bb-alert alert alert-success' style='x_x_str'>'x_x_str'>'x_x_str'>'display: none;'>
        'x_x_str'>'x_x_tag'>'x_x_tag'><span>The examples populate 'x_x_str'>'x_x_keyword'>'x_x_keyword'>this alert 'x_x_str'>'x_x_keyword'>'x_x_keyword'>with dummy content'x_x_str'>'x_x_tag'>'x_x_tag'></span>
    'x_x_str'>'x_x_tag'>'x_x_tag'></div>
    'x_x_str'>'x_x_tag'>'x_x_tag'><div class='x_x_str'>'x_x_str'>'x_x_str'>'container'>
        'x_x_str'>'x_x_tag'>'x_x_tag'><p>'x_x_str'>'x_x_tag'>'x_x_tag'></p>
        'x_x_str'>'x_x_tag'>'x_x_tag'><div class='x_x_str'>'x_x_str'>'x_x_str'>'row'>
            'x_x_str'>'x_x_tag'>'x_x_tag'><div class='x_x_str'>'x_x_str'>'x_x_str'>'col-md-12'>
                'x_x_str'>'x_x_tag'>'x_x_tag'><a href='x_x_str'>'x_x_str'>'x_x_str'>'#' data-bb='x_x_str'>'x_x_str'>'x_x_str'>'alert' class='x_x_str'>'x_x_str'>'x_x_str'>'bb-trigger btn btn-info'>Launch Model'x_x_str'>'x_x_tag'>'x_x_tag'></a>
                'x_x_str'>'x_x_tag'>'x_x_tag'><a href='x_x_str'>'x_x_str'>'x_x_str'>'#' data-bb='x_x_str'>'x_x_str'>'x_x_str'>'alert_callback' class='x_x_str'>'x_x_str'>'x_x_str'>'btn btn-info'>Alert 'x_x_str'>'x_x_tag'>'x_x_tag'><i class='x_x_str'>'x_x_str'>'x_x_str'>'glyphicon glyphicon-play'>'x_x_str'>'x_x_tag'>'x_x_tag'></i>'x_x_str'>'x_x_tag'>'x_x_tag'></a>
                'x_x_str'>'x_x_tag'>'x_x_tag'><a href='x_x_str'>'x_x_str'>'x_x_str'>'#' data-bb='x_x_str'>'x_x_str'>'x_x_str'>'confirm' class='x_x_str'>'x_x_str'>'x_x_str'>'btn btn-info'>Confirm 'x_x_str'>'x_x_tag'>'x_x_tag'><i class='x_x_str'>'x_x_str'>'x_x_str'>'glyphicon glyphicon-play'>'x_x_str'>'x_x_tag'>'x_x_tag'></i>'x_x_str'>'x_x_tag'>'x_x_tag'></a>
                'x_x_str'>'x_x_tag'>'x_x_tag'><a href='x_x_str'>'x_x_str'>'x_x_str'>'#' data-bb='x_x_str'>'x_x_str'>'x_x_str'>'prompt' class='x_x_str'>'x_x_str'>'x_x_str'>'btn btn-info'>Prompt 'x_x_str'>'x_x_tag'>'x_x_tag'><i class='x_x_str'>'x_x_str'>'x_x_str'>'glyphicon glyphicon-play'>'x_x_str'>'x_x_tag'>'x_x_tag'></i>'x_x_str'>'x_x_tag'>'x_x_tag'></a>
                'x_x_str'>'x_x_tag'>'x_x_tag'><a href='x_x_str'>'x_x_str'>'x_x_str'>'#' data-bb='x_x_str'>'x_x_str'>'x_x_str'>'dialog' class='x_x_str'>'x_x_str'>'x_x_str'>'btn btn-info'>Custom Dialog 'x_x_str'>'x_x_tag'>'x_x_tag'><i class='x_x_str'>'x_x_str'>'x_x_str'>'glyphicon glyphicon-play'>'x_x_str'>'x_x_tag'>'x_x_tag'></i>'x_x_str'>'x_x_tag'>'x_x_tag'></a>
            'x_x_str'>'x_x_tag'>'x_x_tag'></div>
        'x_x_str'>'x_x_tag'>'x_x_tag'></div>
    'x_x_str'>'x_x_tag'>'x_x_tag'></div>
'x_x_str'>'x_x_tag'>'x_x_tag'></div>
'x_x_str'>'x_x_tag'>'x_x_tag'><script src='x_x_str'>'x_x_str'>'x_x_str'>'~/Scripts/jquery-2.1.1.min.js'>'x_x_str'>'x_x_tag'>'x_x_tag'></script>
'x_x_str'>'x_x_tag'>'x_x_tag'><script src='x_x_str'>'x_x_str'>'x_x_str'>'~/Scripts/example.js'>'x_x_str'>'x_x_tag'>'x_x_tag'></script>
'x_x_str'>'x_x_tag'>'x_x_tag'><script src='x_x_str'>'x_x_str'>'x_x_str'>'~/Scripts/bootstrap/js/bootstrap.min.js'>'x_x_str'>'x_x_tag'>'x_x_tag'></script>
'x_x_str'>'x_x_tag'>'x_x_tag'><script>
    $'x_x_str'>'x_x_bracket'>'x_x_bracket'>('x_x_keyword'>function 'x_x_str'>'x_x_bracket'>'x_x_bracket'>('x_x_str'>'x_x_bracket'>'x_x_bracket'>) 'x_x_str'>'x_x_bracket'>'x_x_bracket'>{
        Example'x_x_str'>'x_x_selector'>'x_x_selector'>.init'x_x_str'>'x_x_bracket'>'x_x_bracket'>('x_x_str'>'x_x_bracket'>'x_x_bracket'>{
            'x_x_str'>'x_x_str'>'x_x_str'>'selector': 'x_x_str'>'x_x_str'>'x_x_str'>'.bb-alert'
        'x_x_str'>'x_x_bracket'>'x_x_bracket'>}'x_x_str'>'x_x_bracket'>'x_x_bracket'>);
    'x_x_str'>'x_x_bracket'>'x_x_bracket'>}'x_x_str'>'x_x_bracket'>'x_x_bracket'>);
'x_x_str'>'x_x_tag'>'x_x_tag'></script>
'x_x_str'>'x_x_tag'>'x_x_tag'><script src='x_x_str'>'x_x_str'>'x_x_str'>'~/Scripts/bootstrap/bootbox.min.js'>'x_x_str'>'x_x_tag'>'x_x_tag'></script>
'x_x_str'>'x_x_tag'>'x_x_tag'><script src='x_x_str'>'x_x_str'>'x_x_str'>'~/Scripts/demos.js'>'x_x_str'>'x_x_tag'>'x_x_tag'></script>
'x_x_str'>'x_x_the-num'>
'x_x_the-num'>

Example.js:

'x_x_>'x_x_>'x_x_comment'>'x_x_comment'>/**
 * 'x_x_>'x_x_str'>'x_x_keyword'
>This
tiny script just helps us demonstrate
 * what the various example callbacks are doing
 */
var Example = 'x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>(function 'x_x_>'x_x_str'>'x_x_bracket'>'x_x_>'x_x_bracket'>'x_x_bracket'>('x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>) 'x_x_>'x_x_str'>'x_x_bracket'>'x_x_>'x_x_bracket'>'x_x_bracket'>{
    'x_x_>'x_x_>'x_x_str'>'x_x_str'>'use strict';
 
    var elem,
        hideHandler,
        that = 'x_x_>'x_x_str'>'x_x_bracket'
>'x_x_>'x_x_bracket'>'x_x_bracket'>{'x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>};
 
    that'x_x_>'x_x_str'>'x_x_selector'
>'x_x_>'x_x_selector'>'x_x_selector'>.init = function 'x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>(options'x_x_>'x_x_str'>'x_x_bracket'>'x_x_>'x_x_bracket'>'x_x_bracket'>) 'x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>{
        elem = $'x_x_>'x_x_str'>'x_x_bracket'
>'x_x_>'x_x_bracket'>'x_x_bracket'>(options'x_x_>'x_x_>'x_x_selector'>'x_x_selector'>.selector'x_x_>'x_x_str'>'x_x_bracket'>'x_x_>'x_x_bracket'>'x_x_bracket'>);
    'x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>};
 
    that'x_x_>'x_x_str'>'x_x_selector'
>'x_x_>'x_x_selector'>'x_x_selector'>.show = function 'x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>(text'x_x_>'x_x_str'>'x_x_bracket'>'x_x_>'x_x_bracket'>'x_x_bracket'>) 'x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>{
        clearTimeout'x_x_>'x_x_str'>'x_x_bracket'
>'x_x_>'x_x_bracket'>'x_x_bracket'>(hideHandler'x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>);
 
        elem'x_x_>'x_x_str'>'x_x_selector'
>'x_x_>'x_x_selector'>'x_x_selector'>.find'x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>('x_x_>'x_x_str'>'x_x_str'>'x_x_>'x_x_str'>'x_x_str'>'span''x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>)'x_x_>'x_x_str'>'x_x_selector'>'x_x_>'x_x_selector'>'x_x_selector'>.html'x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>(text'x_x_>'x_x_str'>'x_x_bracket'>'x_x_>'x_x_bracket'>'x_x_bracket'>);
        elem'x_x_>'x_x_>'x_x_selector'>'x_x_selector'>.delay'x_x_>'x_x_str'>'x_x_bracket'>'x_x_>'x_x_bracket'>'x_x_bracket'>('x_x_>'x_x_>'x_x_num'>'x_x_num'>200'x_x_>'x_x_str'>'x_x_bracket'>'x_x_>'x_x_bracket'>'x_x_bracket'>)'x_x_>'x_x_>'x_x_selector'>'x_x_selector'>.fadeIn'x_x_>'x_x_str'>'x_x_bracket'>'x_x_>'x_x_bracket'>'x_x_bracket'>('x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>)'x_x_>'x_x_str'>'x_x_selector'>'x_x_>'x_x_selector'>'x_x_selector'>.delay'x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>('x_x_>'x_x_str'>'x_x_num'>'x_x_>'x_x_num'>'x_x_num'>4000'x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>)'x_x_>'x_x_str'>'x_x_selector'>'x_x_>'x_x_selector'>'x_x_selector'>.fadeOut'x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>('x_x_>'x_x_str'>'x_x_bracket'>'x_x_>'x_x_bracket'>'x_x_bracket'>);
    'x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>};
 
    return that;
'x_x_>'x_x_str'>'x_x_bracket'
>'x_x_>'x_x_bracket'>'x_x_bracket'>}'x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>('x_x_>'x_x_str'>'x_x_bracket'>'x_x_>'x_x_bracket'>'x_x_bracket'>)'x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>);
'x_x_>'x_x_str'>'x_x_the-num'>
'x_x_>'x_x_the-num'>
'x_x_the-num'>

 

Demo.js:

'x_x_>'x_x_>'x_x_comment'>'x_x_comment'>/**
 * Bootbox Demos; crude, but effective...
 */

$'x_x_>'x_x_str'>'x_x_bracket'
>'x_x_>'x_x_bracket'>'x_x_bracket'>(function 'x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>('x_x_>'x_x_str'>'x_x_bracket'>'x_x_>'x_x_bracket'>'x_x_bracket'>) 'x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>{
    var demos = 'x_x_>'x_x_str'>'x_x_bracket'
>'x_x_>'x_x_bracket'>'x_x_bracket'>{'x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>};
 
    $'x_x_>'x_x_str'>'x_x_bracket'
>'x_x_>'x_x_bracket'>'x_x_bracket'>(document'x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>)'x_x_>'x_x_str'>'x_x_selector'>'x_x_>'x_x_selector'>'x_x_selector'>.on'x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>('x_x_>'x_x_str'>'x_x_str'>'x_x_>'x_x_str'>'x_x_str'>'click', 'x_x_>'x_x_>'x_x_str'>'x_x_str'>'a[data-bb]', function 'x_x_>'x_x_str'>'x_x_bracket'>'x_x_>'x_x_bracket'>'x_x_bracket'>(e'x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>) 'x_x_>'x_x_str'>'x_x_bracket'>'x_x_>'x_x_bracket'>'x_x_bracket'>{
        e'x_x_>'x_x_>'x_x_selector'>'x_x_selector'>.preventDefault'x_x_>'x_x_str'>'x_x_bracket'>'x_x_>'x_x_bracket'>'x_x_bracket'>('x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>);
        var type = $'x_x_>'x_x_str'>'x_x_bracket'
>'x_x_>'x_x_bracket'>'x_x_bracket'>(this'x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>)'x_x_>'x_x_str'>'x_x_selector'>'x_x_>'x_x_selector'>'x_x_selector'>.data'x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>('x_x_>'x_x_str'>'x_x_str'>'x_x_>'x_x_str'>'x_x_str'>'bb''x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>);
 
        if 'x_x_>'x_x_str'>'x_x_bracket'
>'x_x_>'x_x_bracket'>'x_x_bracket'>(typeof demos'x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>[type'x_x_>'x_x_str'>'x_x_bracket'>'x_x_>'x_x_bracket'>'x_x_bracket'>] === 'x_x_>'x_x_>'x_x_str'>'x_x_str'>'function''x_x_>'x_x_str'>'x_x_bracket'>'x_x_>'x_x_bracket'>'x_x_bracket'>) 'x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>{
            demos'x_x_>'x_x_str'>'x_x_bracket'
>'x_x_>'x_x_bracket'>'x_x_bracket'>[type]'x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>('x_x_>'x_x_str'>'x_x_bracket'>'x_x_>'x_x_bracket'>'x_x_bracket'>);
        'x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>}
    'x_x_>'x_x_str'>'x_x_bracket'
>'x_x_>'x_x_bracket'>'x_x_bracket'>}'x_x_>'x_x_>'x_x_bracket'>'x_x_bracket'>);
 
   // let's namespace the demo methods; it makes them easier
    // to invoke
    demos'x_x_selector'>.alert
= 'x_x_keyword'>function
'x_x_bracket'>('x_x_bracket'>) 'x_x_bracket'>{
        bootbox'x_x_selector'>.alert'x_x_bracket'>('x_x_str'>'Hello world!''x_x_bracket'>);
    'x_x_bracket'>};
 
    demos'x_x_selector'>.alert_callback = 'x_x_keyword'>function 'x_x_bracket'>('x_x_bracket'>) 'x_x_bracket'>{
        bootbox'x_x_selector'>.alert'x_x_bracket'>('x_x_str'>'Hello world!', 'x_x_keyword'>function 'x_x_bracket'>('x_x_bracket'>) 'x_x_bracket'>{
            Example'x_x_selector'>.show'x_x_bracket'>('x_x_str'>'Alert Dialog''x_x_bracket'>);
        'x_x_bracket'>}'x_x_bracket'>);
    'x_x_bracket'>};
 
    demos'x_x_selector'>.confirm = 'x_x_keyword'>function 'x_x_bracket'>('x_x_bracket'>) 'x_x_bracket'>{
        bootbox'x_x_selector'>.confirm'x_x_bracket'>('x_x_str'>'Are you sure?', 'x_x_keyword'>function 'x_x_bracket'>(result'x_x_bracket'>) 'x_x_bracket'>{
            Example'x_x_selector'>.show'x_x_bracket'>('x_x_str'>'Confirm result: ' + result'x_x_bracket'>);
        'x_x_bracket'>}'x_x_bracket'>);
    'x_x_bracket'>};
 
    demos'x_x_selector'>.alert_button = 'x_x_keyword'>function 'x_x_bracket'>('x_x_bracket'>) 'x_x_bracket'>{
        bootbox'x_x_selector'>.alert'x_x_bracket'>('x_x_str'>'This alert has custom button text', 'x_x_str'>'So it does!''x_x_bracket'>);
    'x_x_bracket'>};
 
    demos'x_x_selector'>.confirm_buttons = 'x_x_keyword'>function 'x_x_bracket'>('x_x_bracket'>) 'x_x_bracket'>{
        bootbox'x_x_selector'>.confirm'x_x_bracket'>('x_x_str'>'This confirm has custom buttons - see?', 'x_x_str'>'No', 'x_x_str'>'Yes!', 'x_x_keyword'>function 'x_x_bracket'>(result'x_x_bracket'>) 'x_x_bracket'>{
            'x_x_keyword'>if 'x_x_bracket'>(result'x_x_bracket'>) 'x_x_bracket'>{
                Example'x_x_selector'>.show'x_x_bracket'>('x_x_str'>'Well done!''x_x_bracket'>);
            'x_x_bracket'>} 'x_x_keyword'>else 'x_x_bracket'>{
                Example'x_x_selector'>.show'x_x_bracket'>('x_x_str'>'Oh no - try again!''x_x_bracket'>);
            'x_x_bracket'>}
        'x_x_bracket'>}'x_x_bracket'>);
    'x_x_bracket'>};
 
    demos'x_x_selector'>.prompt = 'x_x_keyword'>function 'x_x_bracket'>('x_x_bracket'>) 'x_x_bracket'>{
        bootbox'x_x_selector'>.prompt'x_x_bracket'>('x_x_str'>'What is your name?', 'x_x_keyword'>function 'x_x_bracket'>(result'x_x_bracket'>) 'x_x_bracket'>{
            'x_x_keyword'>if 'x_x_bracket'>(result === 'x_x_keyword'>null'x_x_bracket'>) 'x_x_bracket'>{
                Example'x_x_selector'>.show'x_x_bracket'>('x_x_str'>'Prompt dismissed''x_x_bracket'>);
            'x_x_bracket'>} 'x_x_keyword'>else 'x_x_bracket'>{
                Example'x_x_selector'>.show'x_x_bracket'>('x_x_str'>'Hi <b>' + result + 'x_x_str'>'</b>''x_x_bracket'>);
            'x_x_bracket'>}
        'x_x_bracket'>}'x_x_bracket'>);
    'x_x_bracket'>};
 
    demos'x_x_selector'>.dialog = 'x_x_keyword'>function 'x_x_bracket'>('x_x_bracket'>) 'x_x_bracket'>{
        bootbox'x_x_selector'>.dialog'x_x_bracket'>('x_x_bracket'>{
            'x_x_attribute'>message: 'x_x_str'>'I am a custom dialog',
            'x_x_attribute'>title: 'x_x_str'>'Custom title',
            'x_x_attribute'>buttons: 'x_x_bracket'>{
                'x_x_attribute'>success: 'x_x_bracket'>{
                    'x_x_attribute'>label: 'x_x_str'>'Success!',
                    'x_x_attribute'>className: 'x_x_str'>'btn-success',
                    'x_x_attribute'>callback: 'x_x_keyword'>function 'x_x_bracket'>('x_x_bracket'>) 'x_x_bracket'>{
                        Example'x_x_selector'>.show'x_x_bracket'>('x_x_str'>'great success''x_x_bracket'>);
                    'x_x_bracket'>}
                'x_x_bracket'>},
                'x_x_attribute'>danger: 'x_x_bracket'>{
                    'x_x_attribute'>label: 'x_x_str'>'Danger!',
                    'x_x_attribute'>className: 'x_x_str'>'btn-danger',
                    'x_x_attribute'>callback: 'x_x_keyword'>function 'x_x_bracket'>('x_x_bracket'>) 'x_x_bracket'>{
                        Example'x_x_selector'>.show'x_x_bracket'>('x_x_str'>'uh oh, look out!''x_x_bracket'>);
                    'x_x_bracket'>}
                'x_x_bracket'>},
                'x_x_attribute'>main: 'x_x_bracket'>{
                    'x_x_attribute'>label: 'x_x_str'>'Click ME!',
                    'x_x_attribute'>className: 'x_x_str'>'btn-primary',
                    'x_x_attribute'>callback: 'x_x_keyword'>function 'x_x_bracket'>('x_x_bracket'>) 'x_x_bracket'>{
                        Example'x_x_selector'>.show'x_x_bracket'>('x_x_str'>'Primary button''x_x_bracket'>);
                    'x_x_bracket'>}
                'x_x_bracket'>}
            'x_x_bracket'>}
        'x_x_bracket'>}'x_x_bracket'>);
    'x_x_bracket'>};
 
'x_x_bracket'>}'x_x_bracket'>);
'x_x_>'x_x_str'>'x_x_the-num'>
'x_x_>'x_x_the-num'>
'x_x_the-num'>

 Output:

Use of Bootbox.js in bootstrap framework


In my next post, I'll explain Getting started with KnockoutJS in ASP.NET MVC 4

Last updated:12/22/2019 8:49:58 AM
Anonymous User

Anonymous User

I am a content writter !

0 Comments

Leave Comment