I am facing an issue with a checkbox that is supposed to save to the database immediately after the value changes. The checkbox is linked to the data element called 'audit'. Below is how the checkbox is implemented in the template:
{{view Site.ReleaseChecklistToggleView checkedBinding="audit" contentBinding="this" placeholder="#"}}
Here is the definition of Site.ReleaseChecklistToggleView
:
Site.ReleaseChecklistToggleView = Em.Checkbox.extend(
change: (e)->
this.content.save()
)
It seems like the 'audit' variable is not getting set before the 'change' function is triggered. As a result, it sends 'null' as the value to the database. However, if I log this.content.audit
within the 'change' method, it correctly shows either 'true' or 'false'. This leads me to believe that the Ember model is not getting updated until after the 'change' method runs.
Can anyone offer guidance on this issue? Is there a better approach I should be taking?