我在骨干中遇到问题,当我从以下html中选择一个选项时,骨干中的事件不会触发。我需要知道选择了哪个城市。
<div id="location">
<label>Select City</label>
<select id="citySelect">
<option value="San Francisco">San Francisco</option>
<option value="Los Angeles">Los Angeles</option>
<option value="New York">New York</option>
<option value="Las Vegas">Las Vegas</option>
</select>
</div>
骨干代码:
var cardsView = Backbone.View.extend({
el: 'body',
intialize: function(){
_.bindAll(this, 'onselect', 'onclick');
this.render();
},
render: function(){
return this;
},
events: {
'change #citySelect': 'onselect'
},
onclick: function (evt) {
console.log('click');
console.log($(evt.currentTarget).val());
alert($(evt.currentTarget).val());
},
onselect: function (evt) {
alert(this.$('#citySelect').val());
}
});
var card = new cardsView();