I want to make a notification like this :
it is only a flash[:notice] with some CSS trick in Ruby On Rails? or it there any other trick on th开发者_StackOverflowis?
You can use this jQuery plugin to simulate the effect. Just wrap the JS in a conditional which checks the flash (or session/db if you want a persistent message)
<% if flash[:notice] or session[:notice] or current_user.notifications %>
$(function () {
$.notifyBar({
html: "<%= flash[:notice] %>",
delay: 2000,
animationSpeed: "normal"
});
});
<% end %>
You will have to style it, obviously.
Yes, in Rails the way to handle this is by using the flash
and styling to suit.
It does not really have to do with Ruby On Rails. If you only want the notice without animation, it's just some CSS. Else it requires Javascript, and is easily done with libraries like jQuery. But even without a library, this would not be very hard.
精彩评论