My controller looks like this:
App.ExaminationController = Ember.ObjectController.extend
amountErrors: null
actions:
saveChanges: ->
if @get('model.isDirty')
@get('model').save().then(
->
(errors) ->
@setAmountErrors errors
)
cancelChanges: ->
@get('model').rollback()
submitValue: ( ->
if @get('isDirty')
'Zapisz'
else
'OK'
).property('isDirty')
setAmountErrors: (errors) ->
if errors.errors.amount
@amountErrors = errors.errors.amount[0]a
console.log @amountErrors
When the line @setAmountErrors errors
is executed i get TypeError: undefined is not a function
And although i tried and validated my code i looks like it's syntax is ok to me. I tried to modify it in all the possible ways of which i could think of. And when I drop the function call and write function call instead the function call like this:
App.ExaminationController = Ember.ObjectController.extend
amountErrors: null
actions:
saveChanges: ->
if @get('model.isDirty')
@get('model').save().then(
->
(errors) ->
if errors.errors.amount
@amountErrors = errors.errors.amount[0]
console.log @amountErrors
)
cancelChanges: ->
@get('model').rollback()
submitValue: ( ->
if @get('isDirty')
'Zapisz'
else
'OK'
).property('isDirty')
It suddenly started to work like intended. But i want to call a function and not write away body of this function. How to do it? What am I missing? Does it has to do anything with my coffescript code, or am I missing something in the Ember controller itself?
Aucun commentaire:
Enregistrer un commentaire