0
var o = Backbone.View.extend({          
    template: [
        '<label>ok1</label>',
        '<select class="test1"><option>111</option><option>222</option></select>',
        '<label>ok2</label>',
        '<select class="test2" multiple="true" ><option>aaa</option><option>bbb</option><option>ccc</option></select>'
    ].join(''),

    events: {
        'change select': 'foo'
    },

    foo: function(){
        console.log('change');
    }
});

The change event work for ok1 when ok1 changed, but when I click the ok2 options, the change event doesn't catch, and I have try many ways to catch the ok2 options selected.
I'm new to backbone.js.
Can somebody help me?

4

1 回答 1

0

该代码在 jsfiddle 上运行良好,就像 @nikoshr 的评论一样,我不知道为什么它在我的环境中不起作用,我将事件更改为这样:

events: {
    'change select': 'foo',
    'click option': 'foo'
},

这对我来说很好。

于 2013-09-09T09:19:39.080 回答