Sub Class a Backbone.View Sub Class & retain events

前端 未结 5 1386
被撕碎了的回忆
被撕碎了的回忆 2020-12-23 17:29

I have a generic subclass of Backbone.View which has a close event listener.

var GenericView = Backbone.View.extend({

    events          


        
5条回答
  •  心在旅途
    2020-12-23 18:06

    I like Mr. Shaver's solution, but for something less intrusive:

    var ChildView = ParentView.extend({
        events : _.extend({
            "change input": "handleInputChange"
        }, ParentView.prototype.events)
    });
    

    Edit: Yes, you have to do this in each child class, but it's useful when only a few children are needed, or when you don't control the parent "class".

提交回复
热议问题