update some templates
This commit is contained in:
parent
429549027f
commit
d7a77e672b
|
@ -4,4 +4,11 @@ describe '<%= plural_object_name %>', ->
|
||||||
withServer()
|
withServer()
|
||||||
|
|
||||||
it 'should fetch records from the API', ->
|
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)
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ class window.<%= object_name %>View extends Backbone.View
|
||||||
render: =>
|
render: =>
|
||||||
$(@el).html(@template(@model.toJSON()))
|
$(@el).html(@template(@model.toJSON()))
|
||||||
this.$('button.save').text(if @model.isNew() then 'Create' else 'Update')
|
this.$('button.save').text(if @model.isNew() then 'Create' else 'Update')
|
||||||
|
this.$('button.delete')[if @model.isNew() then 'hide' else 'show']();
|
||||||
this
|
this
|
||||||
save: =>
|
save: =>
|
||||||
@model.save(@attributes())
|
@model.save(@attributes())
|
||||||
|
|
|
@ -16,6 +16,7 @@ var <%= object_name %>View = Backbone.View.extend({
|
||||||
render: function() {
|
render: function() {
|
||||||
$(this.el).html(this.template(this.model.toJSON()));
|
$(this.el).html(this.template(this.model.toJSON()));
|
||||||
this.$('button.save').text(this.model.isNew() ? 'Create' : 'Update');
|
this.$('button.save').text(this.model.isNew() ? 'Create' : 'Update');
|
||||||
|
this.$('button.delete')[this.model.isNew() ? 'hide' : 'show']();
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
save: function() {
|
save: function() {
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
<!-- your <%= object_name %>View template fields go here -->
|
<!-- your <%= object_name %>View template fields go here -->
|
||||||
<button class="save" /><button class="delete" />
|
<button class="save" /><button class="delete">Delete</button>
|
||||||
|
|
Loading…
Reference in New Issue