Mateusz Urbański
Mateusz Urbański

Reputation: 7862

Closing bootstrap alert

I'm using https://github.com/thoughtbot/paul_revere gem for managing announcements in my rails app. This gem has its partial to show announcements. It looks like this:

<% if announcement_visible?(current_announcement) %>
  <div id="announcement">
    <span><%= current_announcement.body.html_safe %></span>
    <span class="hide">
      <%= link_to "hide", "#", onclick: "hideAnnouncement('#{current_announcement.to_cookie_key}')" %>
    </span>
  </div>
<% end %>

I've add a little bit of css for it:

#announcement{
  position: relative;
  left: 10px;
  width: 50%;

  @extend .alert;
  @extend .alert-dismissible;
  @extend .alert-info;
  @extend .animated;
  @extend .fadeInUp;
}

and it looks like this: enter image description here

But I cant make it work that hide link to hide alert. And I also want to have x instead of hide. Is there any way of doing that with pure css and without overriding gem partial?

Upvotes: 0

Views: 49

Answers (1)

Praveen Kumar Purushothaman
Praveen Kumar Purushothaman

Reputation: 167182

If you are not able to change it in the source or in the gem file, can you please add this jQuery bit?

$(document).ready(function () {
  $("#announcement").find(".hide").html("&times;").attr("data-dismiss", "alert");
});

Upvotes: 1

Related Questions