Skip to content
This repository has been archived by the owner on Jul 31, 2019. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Update selected class on router for filters
  • Loading branch information
adambeynon committed Dec 17, 2013
1 parent f52992d commit 1ede739
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/app.rb
Expand Up @@ -28,6 +28,7 @@ def router

def apply_filter(filter)
Todo.all.each { |t| t.trigger :filter, filter }
@app_view.show_filter filter
end
end

Expand Down
14 changes: 11 additions & 3 deletions app/views/app_view.rb
Expand Up @@ -25,8 +25,6 @@ def initialize
Todo.on(:update) { render }
Todo.on(:destroy) { render }

@template = Template['footer']

Todo.adapter.find_all(Todo) do |models|
models.each { |m| add_todo m }
end
Expand All @@ -45,7 +43,17 @@ def render
@completed = Todo.completed.size
@active = Todo.active.size

@footer.html = @template.render(self)
@footer.html = template.render(self)
end

def show_filter(filter)
links = @footer.find 'li a'
links.remove_class 'selected'
links.filter("a[href=\"#/#{filter}\"]").add_class 'selected'
end

def template
Template['footer']
end

def todo_count
Expand Down

0 comments on commit 1ede739

Please sign in to comment.