Giter VIP home page Giter VIP logo

backbone-composite-keys's People

Contributors

caseywebdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

backbone-composite-keys's Issues

isNew is always false

Backbone is always doing a PUT on models with a composite key, no matter if they are new or not. I'm assuming because of the generated ID the isNew property is always set to false.

collection.get does not return unsaved models in 0.9.9

Backbone 0.9.9 's collection.get method was changed to separately check @_byId and @_byCid:

https://github.com/documentcloud/backbone/blob/0.9.9/backbone.js#L737

Unfortunately, the current master has already reverted back to the 0.9.2 behavior of having a single @_byId, so any change made would be just for 0.9.9.

I tried splitting it out like this:

 return this._byId[obj.id || @model::_generateId(obj) || obj] || this._byCid[obj.cid || obj]

Only to find that @model::_generateId(obj) causes another error when collection.model is defined as a function (as recommended in jashkenas/backbone#793), as collection.model.prototype isn't the model's own prototype. I've removed that specific _generateId call in my project to get it functional for now - what's the scenario where both the id and cid are blank? The final version I'm running for the moment (which seems to work for my use cases) is:

 return this._byId[obj.id || obj] || this._byCid[obj.cid || obj]

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.