Skip to content

Instantly share code, notes, and snippets.

@taylorlapeyre
Last active August 29, 2015 14:17
Show Gist options
  • Save taylorlapeyre/069932a5a0042b7eda40 to your computer and use it in GitHub Desktop.
Save taylorlapeyre/069932a5a0042b7eda40 to your computer and use it in GitHub Desktop.
var SelectThing = Backbone.View.extend({
events: {
'input .select1': 'updateFirstSelect',
'input .select2': 'updateSecondSelect'
},
template: _.template($('#select-thing-template').html()),
initialize: function(collection1, collection2) {
this.firstSelectValue = "";
this.secondSelectValue = "";
this.firstSelectItems = collection1;
this.secondSelectItems = collection2;
},
updateFirstSelect: function(e) {
var value = $(e.currentTarget).val();
if (this.secondSelectValue == "whatever") {
// do some logic
}
this.firstSelectValue = value;
},
updateSecondSelect: function(e) {
var value = $(e.currentTarget).val();
if (this.firstSelectValue == "whatever") {
// do some logic
}
this.secondSelectValue = value;
}
render: function() {
this.$el.html(this.template({
firstSelectItems: this.firstSelectItems,
secondSelectItems: this.secondSelectItems
}));
return this;
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment