Skip to content

Instantly share code, notes, and snippets.

@nilcolor
Created April 13, 2012 11:17
Show Gist options
  • Save nilcolor/2376008 to your computer and use it in GitHub Desktop.
Save nilcolor/2376008 to your computer and use it in GitHub Desktop.
"Быстрый" датабиндинг для Backbone.js
events:
"change input": "fieldChanged",
"change select": "selectionChanged",
selectionChanged: (event) ->
field = $ event.currentTarget
value = $("option:selected", field).val()
data = {}
data[field.attr 'id'] = value
this.model.set data
fieldChanged: (event) ->
field = $ event.currentTarget
data = {}
data[field.attr 'id'] = field.val()
this.model.set data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment