brian-mann / backbone.chooser Goto Github PK
View Code? Open in Web Editor NEWEasily track chosen models in collections
License: MIT License
Easily track chosen models in collections
License: MIT License
Because Backbone.Chooser uses a model attribute to store the chosen state, when saving the model, the chosen flag is also sent in the request.
In my scenario, the chosen field is not part of the original data that populated the model. My API doesn't recognize it in the schema, which causes an error.
Would it be possible to set the flag on a "private" property for the model?
Seems to only work if all the passed models are chosen. As soon as the for loop hits an unchosen model it breaks the loop and the effect is the not all passed models get unchosen.
Possibly not a bug, but should be in readme that it will only accept chosen models.
Right now in SingleChooser when one calls collection.choose(model), the previously selected models are removed from the @Chosen array, but the "collection:unchose:one" event is not fired for them. And if the BackboneChooser is not defined on the model then even the "model:unchosen" event is not fired. One really needs to keep a track of the unchosen models as well.
Seeking a way to clear selection at the collection level (single and multiple). There is chooseNone in the MultiChooser, but an option doesn't exist for the SingleChooser.
Thoughts?
It would be nice to be able to unchoose chosen model in SingleChooser
, because right now one has to:
var maybeModel = collection.getFirstChosen();
if (maybeModel) {
collection.unchoose(maybeModel);
}
Maybe like with MultiChooser. getChosen()
and MultiChooser. getFirstChosen()
, the MultiChooser. chooseNone()
can be available on SingleChooser
.
Thank You
Hey Brian,
I'm almost done writing unit tests for this behavior in our implementation, maybe it'd be a better idea if we unit-test the plugin though? Would you be interested in that?
Thanks,
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.