backbone-paginator / backbone-pageable

DEPRECATED!!! backbone-pageable and backbone.paginator have merged. Please use backbone-paginator/backbone.paginator instead.
MIT License
343 stars 64 forks source link

Add ability to override base Backbone.Collection #120

Closed tgriesser closed 10 years ago

tgriesser commented 10 years ago

Currently, if you attempt to set Backbone.Collection to PageableCollection it triggers an infinite loop, because of how Backbone.Collection is referenced in the constructor. This properly references the Collection constructor to prevent this.

wyuenho commented 10 years ago

Thank you!

tgriesser commented 10 years ago

@wyuenho I was going to submit a separate PR but it might be easier for you to go through and fix throughout your projects:

Anywhere there's a _.template it assumes that a _.templateSettings.variable hasn't already been specified... which breaks the templates if it has been set.

Can you go through and explicitly set it to null when compiling:

_.template("<tag>Html <%- data %> here</tag>", null, {variable: null});

This is what i've had to do in things like the pageable helper to get them to work in my project.

wyuenho commented 10 years ago

@tgriesser Done on all 4 of the places. Thanks for heads up!

tgriesser commented 10 years ago

Sure... one more question for you.

So when implementing a pageable collection, if you bootstrap a collection with a whole bunch of models, and then limit them to a certain amount (say 15)... it looks like when you try to collection.get on the id of a model that should be in the collection, but isn't in the current page, it's undefined. Or if you do collection.pluck('id'), it only shows you the id's for the items in the current page. Is this expected behavior?

I was looking to see where this was happening but I was having a hard time following.

wyuenho commented 10 years ago

If the collection is under client or infinite mode, you get grab the model from collection.fullCollection.get. Word of advice: don't try following the code, it's so magical I can't even follow it without looking at the tests. Read the readme :)

Sent from my iPhone

On 24 Oct, 2013, at 11:59 pm, Tim Griesser notifications@github.com wrote:

Sure... one more question for you.

So when implementing a pageable collection, if you bootstrap a collection with a whole bunch of models, and then limit them to a certain amount (say 15)... it looks like when you try to collection.get on the id of a model that should be in the collection, but isn't in the current page, it's undefined. Or if you do collection.pluck('id'), it only shows you the id's for the items in the current page. Is this expected behavior?

I was looking to see where this was happening but I was having a hard time following.

— Reply to this email directly or view it on GitHub.