🔔 Alert..!! Get 2 Month Free Cloud Hosting With $200 Bonus From Digital Ocean ACTIVATE DEAL

Just another jQuery/Bootstrap plugin allows you to dynamically create Bootstrap alerts with various types (success, info, warning, danger) on your web applications.

Bootstrap alert Notification

Documentation

jQuery Bootstrap Alerts v1.0.0

Build status npm version devDependency Status

jQuery plugin to programmatically display bootstrap alerts

Installation

Download

CDN

<script src="https://unpkg.com/[email protected]/dist/jquery.bsAlert.min.js"></script> <!-- OR --> <script src="https://unpkg.com/[email protected]/dist/jquery.bsAlert.js"></script>

Package Managers

Install via yarn:

$ yarn add jquery-bsalert

Install via NPM:

$ npm install jquery-bsalert --save

Usage

Standard Usage

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script src="https://unpkg.com/[email protected]/dist/jquery.bsAlert.min.js"></script>  <script> // When the DOM is loaded $(function() {     if(someCheck) {         $('#form').bsAlert('success', 'It was successful!');     } else {         $('#form').bsAlert('danger', 'Check form fields!');     }          // With all options and their default values     $('#form').bsAlert({         type: 'success',         content: 'Thanks for contacting us!',         clear: true, // Clear previous alerts (default)         dismissible: true, // Make alert dismissible         position: 'default' // 'default' causes alert to appear before the element. Can also accept 'after', or a function to position manually      }); }); </script>

Browserify

$ npm install jquery-bsalert --save
var $ = require('jquery'); require('jquery-bsalert');  $('#form').bsAlert('warning', 'Alert');

Options

type - The type of alert. See http://getbootstrap.com/components/#alerts for the different types allowed. Defaults to 'danger'.

content - The alert's text or html content. Can also be a function, see below for an example.

clear - Whether to clear any previous alert on the same element. Defaults to true.

dismissible - Whether the alert should be dismissible by the user. Defaults to false.

position - Where to position the alert. 'default' appears before the form, 'after' appears after, or a function may be passed for custom positioning.

Using the position option as a function:

$('#form').bsAlert({     // 'this' is bound to the plugin instance     position: function($alert) {         $alert.appendTo('.container');     } });

Using the content option as a function:

$('#form').bsAlert({     // 'this' is bound to the plugin instance     content: function() {         if(this.options.dismissible) {             return 'This is a dismissible alert';         }                  return 'This is not a dismissible alert';     } });

Modify the $.fn.bsAlert object to change default option values:

$.fn.bsAlert.dismissible = true;

License

The MIT License (MIT) Copyright (c) 2019 The jQuery Bootstrap Alerts authors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


You May Also Like