Reputation: 2810
http://getbootstrap.com/javascript/#alerts-examples Under the usage section, it has several js snippets of code. However, merely using markup like
<div class="alert alert-warning fade in">
<a class="close" data-dismiss="alert" href="#">×</a>
a message
</div>
results in a fully functioning alert with a fancy fade in on exit. What does that javascript($(".alert").alert()
) do? Is it for outdated browsers? Is the documentation outdated?
Upvotes: 1
Views: 231
Reputation: 164803
Here's the difference...
When you enable the alert
plugin on your alert
classed element, the plugin registers a click event handler on the element, with a delegate target selector of [data-dismiss="alert"]
.
This is slightly different to the plugin's implicit behaviour (as in, it does this by just including it) of registering a click event handler on the document
itself (same delegate target selector though) in that it moves the event handler closer to the element itself.
The other thing the plugin allows is programmatic closure of the alert by passing in the "close" argument, eg $('.alert').alert('close')
. This still registers a click handler as in the first case above and is equivalent to $('.alert').alert().alert('close')
.
Upvotes: 1