ember-tools
ember-tools copied to clipboard
How do use mixins in models
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