I've tried to remember the close action in Twitter's Bootstrap alerts following this post (Using Bootstrap, have alert box remember close action)
I want users can not see the alert once they have closed it and the page reloads again.
I know that i must to store the status into a cookie, so I used the JQuery function suggested in the above example, but is not working. What am I doing wrong?
Fiddle -> http://jsfiddle.net/kFy5y/
Thanks in advance!!
jQuery(function( $ ){
// Check if alert has been closed
if( $.cookie('alert-box') === 'closed' ){
$('.alert').hide();
}
// Grab your button (based on your posted html)
$('.close').click(function( e ){
// Do not perform default action when button is clicked
e.preventDefault();
/* If you just want the cookie for a session don't provide an expires
Set the path as root, so the cookie will be valid across the whole site */
$.cookie('alert-box', 'closed', { path: '/' });
});
});
Alert
<div class="alert alert-info fade in">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong> ALERT BODY</strong>
</div>