Giter Club home page Giter Club logo

Comments (6)

p3drosola avatar p3drosola commented on June 17, 2024

Looks good! I'd be happy to merge that if you make a PR.

In what situation could this.models[idx].off not be a function?

from backbone.virtualcollection.

mayang avatar mayang commented on June 17, 2024

I had the _rebuildIndex problem on Chrome too. It's because the idx in for (idx in this.models) can be a 'last' and this.models['last'] is a method which doesn't have 'off'. I got it working by switching to a forEach and checking for this.models existence .

from backbone.virtualcollection.

p3drosola avatar p3drosola commented on June 17, 2024

What? I don't understand what you're describing.

for (i in [1, 2, 3]) {
  console.log(i);
}

how is i ever "last"?

from backbone.virtualcollection.

mayang avatar mayang commented on June 17, 2024

Hm. When I do it in the console it doesn't do last but when I do it running the app I'm using Virtual Collection i do get 'last'

for(idx in [1,2,3]) { console.log(idx) }
VM537:2 0
VM537:2 1
VM537:2 2
VM537:2 last
undefined

Might have stuff to do with with the shims we're using.

from backbone.virtualcollection.

p3drosola avatar p3drosola commented on June 17, 2024

that's definitely not normal javascript behaviour... and not an issue VirtualCollection should deal with.

from backbone.virtualcollection.

jacobbuck avatar jacobbuck commented on June 17, 2024

for-in will loop through items in the prototype too. Normally you should use hasOwnProperty() to prevent this behaviour.

I've fixed this in #67 by using _.invoke instead.

from backbone.virtualcollection.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.