pathable / supermodel

Supermodel - Minimal Model Tracking for Backbonejs
http://pathable.github.io/supermodel
MIT License
229 stars 36 forks source link

Modification: Enables a Supermodel to override initialize method. #68

Closed nachocodoner closed 9 years ago

nachocodoner commented 9 years ago

Hi again!

As I stated in other pull requests, I have approached Supermodel to fix and extend functionality for making it even more useful. I have requested two new features so far: local relationships and jsonify. I planned to make some useful functions concerning to inheritance through 'super' method feature but results to be very tricky and not as useful as I expected (Javascript is not prepared to work with inheritance sugar yet).

Modification

This time, however, I bring you the possibility to overcome the constraint to not be able to include your own initialize method when you define a base Supermodel.

var Model = Supermodel.Model.extend({
    initialize: function(options) {
      // My initialize logic
    }
});

Prior to my modification, my initialization logic would override Supermodel's one, therefore the instantiated models would not be prepared to work as Supermodels. Now, it will work well. :D

Enjoy it!