Skip to content

Instantly share code, notes, and snippets.

@nilcolor
Created April 13, 2012 11:14
Show Gist options
  • Save nilcolor/2375977 to your computer and use it in GitHub Desktop.
Save nilcolor/2375977 to your computer and use it in GitHub Desktop.
"Быстрый" датабиндинг для Backbone.js
events: {
"change input": "fieldChanged",
"change select": "selectionChanged",
},
selectionChanged: function(e){
var field = $(e.currentTarget);
var value = $("option:selected", field).val();
var data = {};
data[field.attr('id')] = value;
this.model.set(data);
},
fieldChanged: function(e){
var field = $(e.currentTarget);
var 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