Extend Flash messages' functionality on Rails ? Auto hide, embedded links ? Close button?
I have been using the default built in flash all over my app, but now I realized that I need to have some more functionality with it: - I need the messages t开发者_如何学编程o auto hide avec a given number of seconds (specifiable for each message would be great) - I need to have a little closing button, so the customer can get rid of it whenever - I need to be able to add a simple href link in there that the user can click if he wants
Any good approach in doing this that won't make me go all over my code ?
You can easily achieve this, I recently wrote a post doing exactly this. Checkout the post here. If you are using jQuery then to automatically close the flash messages you can do something like this:
$(document).ready(function () {
$("div[id^='flash_']").fadeOut(3000);
});
You can learn more about jQuery wildcard selection from here.
精彩评论