Skip to content

Instantly share code, notes, and snippets.

@martinmalek
Created November 23, 2013 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinmalek/7615039 to your computer and use it in GitHub Desktop.
Save martinmalek/7615039 to your computer and use it in GitHub Desktop.
How can I set active tab by mixing in jQuery.localStorage variable in a rails erb condition?
<ul class="nav nav-tabs">
<% @booking.booked_rooms.each_with_index do |booked_room, index| %>
<li class=""><a href="#room-<%= index %>" data-toggle="tab"><%= booked_room.door.title %></a> </li>
<% end %>
</ul>
<script type="text/javascript" >
$(".nav-tabs").on('click', function(e) {
localStorage.setItem( 'booking-tab',$('.nav-tabs .active').find("a").attr("href") );
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment