update some templates

This commit is contained in:
John Bintz 2011-05-09 21:47:00 -04:00
parent 429549027f
commit d7a77e672b
4 changed files with 10 additions and 1 deletions

View File

@ -4,4 +4,11 @@ describe '<%= plural_object_name %>', ->
withServer()
it 'should fetch records from the API', ->
collection = new <%= plural_object_name %>()
@server.respondWith('GET', '/<%= plural_underscore_name %>', @validJSONResponse([{id: 1}]))
collection.fetch()
@server.respond()
expect(collection.length).toEqual(1)

View File

@ -13,6 +13,7 @@ class window.<%= object_name %>View extends Backbone.View
render: =>
$(@el).html(@template(@model.toJSON()))
this.$('button.save').text(if @model.isNew() then 'Create' else 'Update')
this.$('button.delete')[if @model.isNew() then 'hide' else 'show']();
this
save: =>
@model.save(@attributes())

View File

@ -16,6 +16,7 @@ var <%= object_name %>View = Backbone.View.extend({
render: function() {
$(this.el).html(this.template(this.model.toJSON()));
this.$('button.save').text(this.model.isNew() ? 'Create' : 'Update');
this.$('button.delete')[this.model.isNew() ? 'hide' : 'show']();
return this;
},
save: function() {

View File

@ -1,2 +1,2 @@
<!-- your <%= object_name %>View template fields go here -->
<button class="save" /><button class="delete" />
<button class="save" /><button class="delete">Delete</button>