我的视图有一个单击处理程序,但是当单击事件处理程序作为目标时,似乎视图el $('#modal')在单击时不会触发。但是,当我针对 的任何孩子时$('modal'),点击事件会在点击时触发。
我猜$('#modal')它不被视为视图的一部分,因此其中定义的单击事件处理程序events对其不起作用。如果是这样,是否有另一种解决方法?
ModalView = Backbone.View.extend({
    el: $('#modal'),
    template: _.template( $('#tpl_modal').html() ),
    events: {
        'click #modal': 'closeModal'
    },
    initialize: function() {
        _.bindAll(this, 'render', 'renderSimilarPosts', 'closeModal');
        this.render();
    },
    render: function() {
        $(this.el).fadeIn('fast').append( this.template( this.model.toJSON( this.model ) ) );
    },
    closeModal: function() {
        // some code
    }
});