Skip to content

Instantly share code, notes, and snippets.

View martinmalek's full-sized avatar

Martin Malek martinmalek

View GitHub Profile
@martinmalek
martinmalek / gist:7615039
Created November 23, 2013 14:13
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") );