Block-alert

Basic

Without close button

Without animation

With timer

Namespaces

|

Custom position

By default, PxBlockAlert plugin places alerts at the top of the container. To change this behavior, you need to insert the .px-block-alerts element to targeted position manually.

Within .px-content

Some page content

Within panel

Panel title
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
Panel title
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
Panel title
Support panel subtitle
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.

Creating an alert

The PxBlockAlert pluginĀ isn't creates/stores a class instance.

$('#element').pxBlockAlert('

Alert content

', options);

Option Default Description
type null Alert type:
  • null - default alert;
  • success;
  • info;
  • warning;
  • danger.
style null Alert style:
  • null - light alert;
  • dark.
namespace default Add alert to the given namespace.
animate true Animate alert.
timer 0 Automatically close alert after timer seconds. 0 - do not close alert automatically.
closeButton true Show close button.

Usage


require(['jquery', 'px/plugins/px-block-alert'], function($) {
  ...
});
        

Methods


$('#element').pxBlockAlert('methodName', arg1, arg2, ...);
        

Method name Description
remove($alert, animate = true) Remove the given $alert.
clear(namespace = 'default', animate = true) Remove all alerts within the given namespace.
clearAll(animate = true) Remove all alerts.
destroy Remove the .px-block-alerts container with all alerts.

Usage

To use PxBlockAlert plugin, you need to include the next scripts:


<script src="path/to/js/pixeladmin/plugins/px-block-alert.js"></script>
<script src="path/to/js/pixeladmin/directives/angular-px-block-alert.js"></script>
        

Then inject the plugin into your angular application:

angular.module('yourApp', ['px-block-alert']);

Alternatively, you can include PxBlockAlert plugin using ocLazyLoad plugin:


$ocLazyLoad.load([
  {
    name: 'px-block-alert',
    files: [
      'path/to/js/pixeladmin/plugins/px-block-alert.js',
      'path/to/js/pixeladmin/directives/angular-px-block-alert.js',
    ],
  },
]);
        

$pxBlockAlert service

Inject $pxBlockAlert service into a controller to create alerts. By default it comes with five methods:

NOTE: Define options.container attribute to specify parent container (Default: .px-content). For example, the next lines of code are equivalent:


// jQuery
$('#some-block').pxBlockAlert('Alert text.', { type: 'danger', closeButton: false });

// Angular
$pxBlockAlert.add('Alert text.', { container: '#some-block', type: 'danger', closeButton: false });
        

  |