Closed itsmepetrov closed 9 years ago
I know very little about Backbone Relational. You'll have to do some testing if you feel that you absolutely must have a single component extend two disparate third-party libraries.
After much frustration, I was able to successfully mixin Backbone.Relational and Epoxy.Model using Backbone.Cocktail like this:
Backbone.Epoxy.Model.prototype._super = Backbone.RelationalModel;
var baseModel = Backbone.RelationalModel.extend({});
var initMixin = {
initialize: function() {
this.initComputeds();
}
};
Cocktail.mixin(baseModel, Backbone.Epoxy.Model.mixin(), initMixin);
var relationalEpoxyModel = new baseModel();
Disclaimer: this will affect all Epoxy.Model instances since you are adding it to the prototype.
~~I think this is not a correct solution, mixin Backbone.Relational & Backbone.Epoxy without change source code is almost impossible.
The most serious problem is both of them(Model for example) treat Backbone.Model as their super Class, which is not always true.~~
Forgive my blinding, I diden't see: Backbone.Epoxy.Model.prototype._super = Backbone.RelationalModel
It's really a good polyfill
How can I use Epoxy.Model with Backbone-relational Model http://backbonerelational.org ? They both override "set" and "get" functions.