ember-tools icon indicating copy to clipboard operation
ember-tools copied to clipboard

How do use mixins in models

Open rauhryan opened this issue 11 years ago • 0 comments

If I define a mixin and try and use it in a model the mixin is undefined on the App object when the model is defined.

var Serializable = Ember.Mixin.create({
  serialize: function () {
    var result = {};
    for (var key in $.extend(true, {}, this))
    {
        // Skip these
        if (key === 'isInstance' ||
        key === 'isDestroyed' ||
        key === 'isDestroying' ||
        key === 'concatenatedProperties' ||
        typeof this[key] === 'function')
        {
            continue;
        }
        result[key] = this[key];
    }
    return result;
  }
});

module.exports = Serializable;
var Model = Ember.Object.extend(App.Serializable, {});

App. Serializable is undefined

rauhryan avatar Nov 14 '13 18:11 rauhryan