I have a form that is bound to a model: user form, which is represented by Backbone.View.extend which has:
model:user
inside the view:
events: {
'click #payment' : 'updatePayment'
}
where payment is a html select with :
<div class="span2" id="payment">
<select class="span12">
<option value="paypal">paypal</option>
<option value="check">check</option>
</select>
</div>
updatePayment: function() {
var payment = this.$("#payment");
console.log(payment);
}
Sadly payment has no value. Can someone please help? Thanks!
It is a bit hard to tell... but it seems like you want this:
events: {
'change .span12' : 'updatePayment' // listen for change of <select> element.
},
updatePayment: function(event) {
var payment = event.target.value;
console.log(payment); // print 'paypal' or 'check'.
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With