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

View file

@ -1,35 +0,0 @@
<h1>New habit</h1>
<form id="new-habit" name="habit">
<div class="field">
<label for="name"> name:</label>
<input type="text" name="name" id="name" value="<%= name %>" >
</div>
<div class="field">
<label for="habit_type"> habit_type:</label>
<input type="text" name="habit_type" id="habit_type" value="<%= habit_type %>" >
</div>
<div class="field">
<label for="notes"> notes:</label>
<input type="text" name="notes" id="notes" value="<%= notes %>" >
</div>
<div class="field">
<label for="up"> up:</label>
<input type="text" name="up" id="up" value="<%= up %>" >
</div>
<div class="field">
<label for="down"> down:</label>
<input type="text" name="down" id="down" value="<%= down %>" >
</div>
<div class="actions">
<input type="submit" value="Create Habit" />
</div>
</form>
<a href="#/index">Back</a>

View file

@ -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) ->

View file

@ -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