Commit 5a823fba authored by Mark Otto's avatar Mark Otto

markdownify js alerts

parent d1f69976
...@@ -3,74 +3,90 @@ layout: page ...@@ -3,74 +3,90 @@ layout: page
title: Alerts title: Alerts
--- ---
<div class="bs-docs-section"> Add dismiss functionality to all alert messages with this plugin.
<h1 id="alerts" class="page-header">Alert messages <small>alert.js</small></h1>
## Examples
<h2 id="alerts-examples">Example alerts</h2>
<p>Add dismiss functionality to all alert messages with this plugin.</p> {% example html %}
<div class="bs-example"> <div class="alert alert-warning alert-dismissible fade in" role="alert">
<div class="alert alert-warning alert-dismissible fade in" role="alert"> <button type="button" class="close" data-dismiss="alert">
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button> <span aria-hidden="true">&times;</span>
<strong>Holy guacamole!</strong> Best check yo self, you're not looking too good. <span class="sr-only">Close</span>
</div> </button>
</div><!-- /example --> <strong>Holy guacamole!</strong> Best check yo self, you're not looking too good.
</div>
<div class="bs-example"> {% endexample %}
<div class="alert alert-danger alert-dismissible fade in" role="alert">
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button> {% example html %}
<h4>Oh snap! You got an error!</h4> <div class="alert alert-danger alert-dismissible fade in" role="alert">
<p>Change this and that and try again. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum.</p> <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<p> <h4>Oh snap! You got an error!</h4>
<button type="button" class="btn btn-danger">Take this action</button> <p>Change this and that and try again. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum.</p>
<button type="button" class="btn btn-secondary">Or do this</button> <p>
</p> <button type="button" class="btn btn-danger">Take this action</button>
</div> <button type="button" class="btn btn-secondary">Or do this</button>
</div><!-- /example --> </p>
</div>
{% endexample %}
<h2 id="alerts-usage">Usage</h2>
<p>Enable dismissal of an alert via JavaScript:</p> ## Usage
{% highlight js %}$(".alert").alert(){% endhighlight %}
Enable dismissal of an alert via JavaScript:
<h3>Markup</h3>
<p>Just add <code>data-dismiss="alert"</code> to your close button to automatically give an alert close functionality.</p> {% highlight js %}
{% highlight html %}<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>{% endhighlight %} $(".alert").alert()
{% endhighlight %}
<h3>Methods</h3>
### Markup
<h4>$().alert()</h4>
<p>Wraps all alerts with close functionality. To have your alerts animate out when closed, make sure they have the <code>.fade</code> and <code>.in</code> class already applied to them.</p> Just add `data-dismiss="alert"` to your close button to automatically give an alert close functionality.
<h4>.alert('close')</h4> {% highlight html %}
<p>Closes an alert.</p> <button type="button" class="close" data-dismiss="alert">
{% highlight js %}$(".alert").alert('close'){% endhighlight %} <span aria-hidden="true">&times;</span>
<span class="sr-only">Close</span>
</button>
<h3>Events</h3> {% endhighlight %}
<p>Bootstrap's alert class exposes a few events for hooking into alert functionality.</p>
<div class="table-responsive"> ### Methods
<table class="table table-bordered table-striped">
<thead> #### $().alert()
<tr>
<th style="width: 150px;">Event Type</th> Wraps all alerts with close functionality. To have your alerts animate out when closed, make sure they have the `.fade` and `.in` class already applied to them.
<th>Description</th>
</tr> #### .alert('close')
</thead>
<tbody> Closes an alert.
<tr>
<td>close.bs.alert</td> {% highlight js %}$(".alert").alert('close'){% endhighlight %}
<td>This event fires immediately when the <code>close</code> instance method is called.</td>
</tr> ### Events
<tr>
<td>closed.bs.alert</td> Bootstrap's alert class exposes a few events for hooking into alert functionality.
<td>This event is fired when the alert has been closed (will wait for CSS transitions to complete).</td>
</tr> <div class="table-responsive">
</tbody> <table class="table table-bordered table-striped">
</table> <thead>
</div><!-- /.table-responsive --> <tr>
<th style="width: 150px;">Event Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>close.bs.alert</td>
<td>This event fires immediately when the <code>close</code> instance method is called.</td>
</tr>
<tr>
<td>closed.bs.alert</td>
<td>This event is fired when the alert has been closed (will wait for CSS transitions to complete).</td>
</tr>
</tbody>
</table>
</div>
{% highlight js %} {% highlight js %}
$('#my-alert').on('closed.bs.alert', function () { $('#my-alert').on('closed.bs.alert', function () {
// do something… // do something…
}) })
{% endhighlight %} {% endhighlight %}
</div>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment