if i am using the devise gem with rails, how do i make the flash messages appear only when theres content inside of it.
does rails have an easy way to do this or do i manually need to do it in jquery?
currently im using twitter bootstrap v2 and it has them built in by default. here is the best jquery i could come up with by the way, im not sure how this could be refactored better (although i definitely know it could be). I had to do it like this because i have an 'x' inside the <p>
flash
if($('.alert-success').clone().children().remove().end().text() != "") {
$('.alert-success').fadeIn();
}
if($('.alert-error').clone().children().remove().end().text() != "") {
$('.alert-error').fadeIn();
}
EDIT: My layout contains:
<p class="alert alert-success"><a class="close" data-dismiss="alert">×</a><%= notice %></p>
<p class="alert alert-error"><a class="close" data-dismiss="alert">×</a><%= alert %></p>
No special methods here, I'd simply control how those tags are output with a surrounding if
:
<% if notice %><p class="alert alert-success"><a class="close" data-dismiss="alert">×</a><%= notice %></p><% end %>
<% if alert %><p class="alert alert-error"><a class="close" data-dismiss="alert">×</a><%= alert %></p><% end %>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.