outback icon indicating copy to clipboard operation
outback copied to clipboard

Create an "on" event binding

Open dzrw opened this issue 13 years ago • 0 comments

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

dzrw avatar Feb 14 '12 17:02 dzrw