Twitter Bootstrap Remember alert action

I tried to remember the next action in Bootstrap Twitter messages after this message ( Using Bootstrap, you have a warning window, remember the closed action )

I want users to not be able to see the warning as soon as they close it and the page will reload again.

I know that I have to save the status in a cookie, so I used the jQuery function suggested in the above example, but it doesn’t work. 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: '/' }); }); }); 

Signal

 <div class="alert alert-info fade in"> <button type="button" class="close" data-dismiss="alert">Γ—</button> <strong> ALERT BODY</strong> </div> 
+6
source share
1 answer

You use $.cookie('alert-box') , which is not a standard jQuery function, but a method implemented in the library, such as jquery cookie .

So you need to add this library or similar to save cookies using jQuery.

+3
source

All Articles