Fixed lost tab after setting has changed.

This commit is contained in:
Martin Edenhofer 2014-08-13 13:20:53 +02:00
parent 604f4c918e
commit 03a1d880d0
2 changed files with 15 additions and 4 deletions

View file

@ -269,14 +269,17 @@ class App.ControllerLevel2 extends App.ControllerContent
# window.scrollTo(0,0) # window.scrollTo(0,0)
class App.ControllerTabs extends App.Controller class App.ControllerTabs extends App.Controller
events:
'click .nav-tabs [data-toggle="tab"]': 'tabRemember',
constructor: -> constructor: ->
super super
render: -> render: ->
@html App.view('generic/tabs')( @html App.view('generic/tabs')(
tabs: @tabs tabs: @tabs
) )
@el.find('.nav-tabs li:first').addClass('active')
for tab in @tabs for tab in @tabs
@el.find('.tab-content').append('<div class="tab-pane" id="' + tab.target + '"></div>') @el.find('.tab-content').append('<div class="tab-pane" id="' + tab.target + '"></div>')
@ -285,7 +288,15 @@ class App.ControllerTabs extends App.Controller
params.el = @el.find( '#' + tab.target ) params.el = @el.find( '#' + tab.target )
new tab.controller( params ) new tab.controller( params )
@el.find('.tab-content .tab-pane:first').addClass('active') @lastActiveTab = @Config.get('lastTab')
if @lastActiveTab && @el.find('.nav-tabs li a[href="' + @lastActiveTab + '"]')[0]
@el.find('.nav-tabs li a[href="' + @lastActiveTab + '"]').tab('show')
else
@el.find('.nav-tabs li:first a').tab('show')
tabRemember: (e) =>
@lastActiveTab = $(e.target).attr('href')
@Config.set('lastTab', @lastActiveTab)
class App.ControllerNavSidbar extends App.ControllerContent class App.ControllerNavSidbar extends App.ControllerContent
constructor: (params) -> constructor: (params) ->

View file

@ -1,6 +1,6 @@
<ul class="nav nav-tabs"> <ul class="nav nav-tabs" role="tablist">
<% for tab in @tabs: %> <% for tab in @tabs: %>
<li><a href="#<%= tab.target %>" data-toggle="tab"><%- @T( tab.name ) %></a></li> <li><a href="#<%= tab.target %>" role="tab" data-toggle="tab"><%- @T( tab.name ) %></a></li>
<% end %> <% end %>
</ul> </ul>
<div class="tab-content"></div> <div class="tab-content"></div>