Comments (5)
Interesting catch ... and thank you for your helpful description! I'll deal with the issue further down the road. I can't say for sure that I'll actually fix it - after all, the issue relates to undocumented Backbone behaviour. On the other hand, Backbone is meant to be hacked, so it would make sense to make it work. I'll have a look.
from backbone.select.
Sorry for the delay ... I've had a closer look now. As far as I can see, a fix would have to replace Backbone.Collection with a modified implementation.
The issue is that Backbone parses the models and creates the models
property after initialize()
is called. That order would have to be reversed. The fix I have in mind would look something like this:
var originalConstructor = Backbone.Collection;
Backbone.Collection = Backbone.Collection.extend( {
constructor: function ( models, options ) {
if ( options && options.parse ) ) {
models = this.parse( models, options ) || [];
options = _.extend( {}, options, { parse: false } );
}
originalConstructor.call( this, models, options );
}
} );
That would do the trick (presumably), but I don't like it for two reasons.
First, the options object handed to initialize()
is no longer the one which was passed in. initialize()
receives a clone, and the parse
option has changed to false
, in order to prevent a second parse call. That alone might be enough to break stuff for some people.
Second, it's a heavy-handed approach. It would place otherwise unneccessary constraints on the load order of components: Backbone.Select would have to be loaded after Backbone, but before anything else.
Imagine the fallout e.g. in an AMD setup. Every component which depends on Backbone would have to list Backbone.Select as a dependency, too. A shim would be required for pretty much every Backbone-related third-party module. I don't think that's worth it, given that we are dealing with an undocumented feature.
So I'll leave things as they are. However, if you disagree or have a different idea for a fix, just let me know. And thanks for the report!
from backbone.select.
I retract everything I've said ;) Seems like I'll be able to fix it cleanly in the upcoming version 2.
from backbone.select.
Sounds great, thanks.
from backbone.select.
Has landed in 2.0.0.
from backbone.select.
Related Issues (12)
- npm publish HOT 2
- Doesn't work when selectable model doesn't descend directly from Backbone.Model HOT 1
- Selected model not deselected when Select.Many is reset with new models HOT 3
- Can I use 'One' mode with different label as 'Many' mode? HOT 3
- Upgrade to BB 1.3.* HOT 1
- [Question] Get current running total of items clicked
- Select.One collections has a moment when two models are selected HOT 1
- Does not work with backbone 1.1.2 HOT 2
- Not Working With Underscore 1.7 or Lodash 1+ HOT 2
- this.selected.select is not a function error message HOT 1
- collections/models with more then one "selected state" HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from backbone.select.