Last active
August 29, 2015 14:17
-
-
Save taylorlapeyre/069932a5a0042b7eda40 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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