Html select baseline value

I have a model-bound form: a custom form, which is represented by Backbone.View.extend, which has:

model:user

inside view:

events: {
   'click #payment' : 'updatePayment'
}

where payment is html selection using:

<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);
}

A sad payment does not matter. Can someone help? Thank!

+5
source share
1 answer

It's a little hard to say ... but it looks 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'.
}
+7
source

All Articles