petermichaux / maria

The MVC framework for JavaScript applications. The real MVC. The Smalltalk MVC. The Gang of Four MVC.
BSD 2-Clause "Simplified" License
764 stars 51 forks source link

uiActions and subclasses #64

Closed petermichaux closed 10 years ago

petermichaux commented 11 years ago

In the following code, the UI actions in myApp.baseView are not inherited by myApp.subView.

maria.ElementView.subclass(myApp, 'baseView', {
    uiActions: {
        'click .foo': 'onClickFoo'
    }
});

myAppBaseView.subclass(myApp, 'subView', {
    uiActions: {
        'click .bar': 'onClickBar'
    }
});

It is necessary to do the following

maria.ElementView.subclass(myApp, 'baseView', {
    uiActions: {
        'click .foo': 'onClickFoo'
    }
});

myAppBaseView.subclass(myApp, 'subView', {
    properties: {
        getUIActions: function() {
            var uiActions = myApp.subView.superConstructor.prototype.getUIActions.call(this);
            uiActions['click .bar'] = 'onClickBar'
            return uiActions;
        },
        onClickBar: function(evt) {
            this.getController().onClickBar(evt);
        }
    }
});
hieuhuynh commented 10 years ago

I took a stab at this to augment the uiActions object. See my pull request: See https://github.com/petermichaux/maria/pull/70

petermichaux commented 10 years ago

I think it should be possible to do the following in order to inherit. The following should be equivalent to the second example in this issue's description.

maria.ElementView.subclass(myApp, 'baseView', {
    uiActions: {
        'click .foo': 'onClickFoo'
    }
});

myAppBaseView.subclass(myApp, 'subView', {
    moreUIActions: {
        'click .bar': 'onClickBar'
    }
});