Start a new topic

Assign custom Modelclass for Collection?

 Hi,



i want to use a custom Model for my Collection Class to base on, but how i can do this?
In the Docs there is
"By default, the model class of the Kinvey.Backbone.Collection is Kinvey.Backbone.Model."
But how i can change this?

I've tried something like this:


 

var M_EVENT = Backbone.Model.extend({
	url : 'events',
	foo : "bar"
});

_.extend(M_EVENT.prototype, Kinvey.Backbone.ModelMixin);

var C_EVENT = Backbone.Collection.extend({
	url : 'events',
	model : M_EVENT
});
_.extend(C_EVENT.prototype, Kinvey.Backbone.CollectionMixin);

Alloy.Collections.events = new C_EVENT([]);

 

But that doesn't really work.

Any hint would be great. :)






Anyone on this? :(



Sorry about the slow reply Nico,


Let me ask someone about this.

Any new on this? :/ 

Nico, 

var M_EVENT = Backbone.Model.extend(
  _.extend({}, Kinvey.Backbone.ModelMixin, {
    url: 'events',
    foo: 'bar'  
  })
);

var C_EVENT = Backbone.Collection.extend(
  _.extend({}, Kinvey.Backbone.CollectionMixin, {
    url: 'events',
    model: M_EVENT
  })  
);
 
Alloy.Collections.events = new C_EVENT([]);

 


Have you tried something like this?



I'll try this!
Login or Signup to post a comment