Remove new_view & new.jst (since creating inline)

This commit is contained in:
Tyler Renelle
2012-02-11 15:11:03 -05:00
parent bd7a49c436
commit 27a6cdf4f9
3 changed files with 2 additions and 72 deletions
@@ -17,6 +17,8 @@ class HabitTracker.Views.Habits.IndexView extends Backbone.View
createOnEnter: (e) ->
input = $(e.target)
if (!input.val() or e.keyCode != 13) then return
# See commit bd7a49c new_view.js.coffee for more code surrounding this functionality
@options.habits.create {name: input.val(), habit_type: input.attr('data-type'), position: @options.habits.nextPosition()},
#TODO what's this all about?
success: (habit) ->
@@ -1,37 +0,0 @@
HabitTracker.Views.Habits ||= {}
class HabitTracker.Views.Habits.NewView extends Backbone.View
template: JST["backbone/templates/habits/new"]
events:
"submit #new-habit": "save"
constructor: (options) ->
super(options)
@model = new @collection.model()
@model.bind("change:errors", () =>
this.render()
)
save: (e) ->
e.preventDefault()
e.stopPropagation()
@model.unset("errors")
@collection.create(@model.toJSON(),
success: (habit) =>
@model = habit
window.location.hash = "#/index"
error: (habit, jqXHR) =>
@model.set({errors: $.parseJSON(jqXHR.responseText)})
)
render: ->
$(@el).html(@template(@model.toJSON() ))
this.$("form").backboneLink(@model)
return this