jmorrell / backbone.obscura

A read-only proxy of a Backbone.Collection that can be filtered, sorted, and paginated.
http://jmorrell.github.io/backbone.obscura/
MIT License
107 stars 19 forks source link

Proxy Collection retrieved is only of single element #22

Closed jrohit closed 10 years ago

jrohit commented 10 years ago

I'm using backbone obscura in my application.

In my require_main.js inside paths I've 'backbone.obscura':'lib/backbone.obscura', and in shim I've 'backbone.obscura' : { deps : [ 'underscore', 'backbone' ], exports : "Obscura" }

I'm pulling in obscura in one of my Marionette view define(['backbone.obscura'], function(Obscura){ // code for view creation. Edited for brevity

showTable : function(){ console.log(this.collection.length); // prints the length of collection which is 10 var proxy = new Obscura(this.collection); console.log(proxy.length); // prints the length of proxy which is one (1) // remaining 9 are not retrieved
var view = new Collectionview({collection : proxy}); } });

Could you please suggest any approach to figure out this issue?

jmorrell commented 10 years ago

Obscura wraps itself in a UMD module. You shouldn't need to shim it as far as I know.

The behavior you mention is odd. Can you print out this.collection.toJSON() and proxy.toJSON()?

jrohit commented 10 years ago

Hi, I Just figured out the solution, my model was having an attribute "id"(as business req) and every model was having a common value (coming from dummy json, for now) for it, so obsucra was not able to differentiate the first model from the rest and therefore returning only first model. I was thinking that this differentiation logic is on model's cid but now when i'm retrieving data from web services its working fine as the "id" attribute is having unique value.

Closing the issue. Thanks a lot for this plugin. It really helped.