mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-05 12:02:13 +00:00
25 lines
706 B
CoffeeScript
25 lines
706 B
CoffeeScript
|
|
class HabitTracker.Routers.HabitsRouter extends Backbone.Router
|
||
|
|
initialize: (options) ->
|
||
|
|
@habits = new HabitTracker.Collections.HabitsCollection()
|
||
|
|
@habits.reset options.habits
|
||
|
|
|
||
|
|
routes:
|
||
|
|
"/new" : "newHabit"
|
||
|
|
"/index" : "index"
|
||
|
|
"/:id/edit" : "edit"
|
||
|
|
".*" : "index"
|
||
|
|
|
||
|
|
newHabit: ->
|
||
|
|
@view = new HabitTracker.Views.Habits.NewView(collection: @habits)
|
||
|
|
$("#habits").html(@view.render().el)
|
||
|
|
|
||
|
|
index: ->
|
||
|
|
@view = new HabitTracker.Views.Habits.IndexView(habits: @habits)
|
||
|
|
$("#habits").html(@view.render().el)
|
||
|
|
|
||
|
|
edit: (id) ->
|
||
|
|
habit = @habits.get(id)
|
||
|
|
|
||
|
|
@view = new HabitTracker.Views.Habits.EditView(model: habit)
|
||
|
|
$("#habits").html(@view.render().el)
|