outback
outback copied to clipboard
Create an "on" event binding
The "on" binding should function as a setter of model attributes. The setter behavior may be extensible. This is not a free-form "eval" binding, and it does not call arbitrary functions on views or models.
# option 1
modelBindings:
'button': on: { eventName: 'click', toggle: modelref 'foo' }
# option 2 - allow multiple setters per selector
modelBindings:
'button': on: { setter: { eventName: 'click', toggle: modelref 'foo' } }
The action may initially be one of toggle
or value
.
The purpose of the "on" handle is to facilitate setting model attributes without the ceremony of:
events:
'click button': 'toggleFoo'
toggleFoo =>
current = @model.get 'foo'
@model.set foo: !current