jashkenas / backbone

Give your JS App some Backbone with Models, Views, Collections, and Events
http://backbonejs.org
MIT License
28.09k stars 5.39k forks source link

findWhere() method not available on Collections #2228

Closed apsoto closed 11 years ago

apsoto commented 11 years ago

Not sure if Collections are proxying all the collection methods, but I noticed that findWhere() is not available.

tgriesser commented 11 years ago

Hold on, that bumps the dependency to 1.4.4...

apsoto commented 11 years ago

reason I noticed is that the backbone docs defers to the underscore collection method docs, which has findWhere() documented.

caseywebdev commented 11 years ago

@tgriesser Nope, no dependency bump...look at the change (it mirrors the underscore implementation, as one would expect).

tgriesser commented 11 years ago

My mistake @caseywebdev, should have looked first!

EvHaus commented 11 years ago

Looks like findWhere is missing from Backbone.Collection() in 1.0.0

philfreo commented 11 years ago

@globexdesigns No, but it's listed separately from the Underscore collection functions

http://backbonejs.org/#Collection-findWhere

EvHaus commented 11 years ago

But when I do:

var collection = new Backbone.Collection() console.log(collection.findWhere)

it returns "undefined"

kimjoar commented 11 years ago

@globexdesigns Are you sure you're running Backbone 1.0.0?

Here it's in the code: https://github.com/documentcloud/backbone/blob/master/backbone.js#L814-816

Here's a fiddle, run it and check the console. You'll see:

function (attrs) {
      return this.where(attrs, true);
    }
JoeChapman commented 11 years ago

Didn't he say findWhere, not where?

Sincerely, Joseph Chapman Managing Director & Principal Developer Creatify Limited http://creatify-limited.com http://josephchapman.com

On 27 Apr 2013, at 08:51, Kim Joar Bekkelund notifications@github.com wrote:

@globexdesigns Are you sure you're running Backbone 1.0.0?

Here it's in the code: https://github.com/documentcloud/backbone/blob/master/backbone.js#L814-816

Here's a fiddle, run it and check the console. You'll see:

function (attrs) { return this.where(attrs, true); } — Reply to this email directly or view it on GitHub.

EvHaus commented 11 years ago

Ok, so maybe there's some condition that's occurring in my code that's causing the function to get undefined. I'll take a look and get back to you. But based on earlier comments, it seems I'm not the only one that this happened to.

shrimpwagon commented 11 years ago

Yeah, collection.findWhere doesn't seem to work. I just used _.findWhere.(collection.models, function(.....

EvHaus commented 11 years ago

Yup. I was not using 1.0.0. This is a non-issue.