Giter VIP home page Giter VIP logo

backbone.select's People

Contributors

aaronbrethorst avatar beng-hee-eu avatar cinaglia avatar dakota avatar hashchange avatar jackca avatar liammclennan avatar marcdel avatar randallion avatar torifat avatar yethee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

backbone.select's Issues

Select.One collections has a moment when two models are selected

Lets assume this:

  • collection is single selectable
  • one model has already been selected
  • we are selecting another one

So we will have:

  • selected event (with the second model)
  • at this point two models are selected
  • deselected event

I beliave we should fire deselected event first (and have zero selected models at some point) and then select the target model.

Not Working With Underscore 1.7 or Lodash 1+

When I was experimenting with substituting lodash for backbone, this mixin stopped working. Looking closer, the extend method in the latest underscore and most lodash versions only copies an objects own properties. Version <=1.6 of underscore will include properties defined on the prototype so the following method was working there:
_.extend( hostObject, new Backbone.Select.One() );

Since I didn't see a need for the instance, I just made the mixins plain objects and passed those to the extend methods like so.
_.extend( hostObject, SelectOneMixin );

I'll attach a PR shortly. Other than that, thanks for this project. It's been very helpful.

Cheers!

collections/models with more then one "selected state"

Hi There,

Thanks for a nice mix in. I've am wondering if it can cover a few usage cases I am not clear about after reading documentation and testing a little bit. Please consider the following cases:

Scenario 1:
A collection where we want to track selected state for a model that has been "starred" and a model that has been "up voted" (tracking two separate selected states for models in the same collection).

Scenario 2:
A model is passed between "collection a" which uses "select one" mix in and "collection b" that uses "select many" mix in. The model had previously been selected in collection a and we want to keep it's selected state until another model is selected or that model is deselected. Additionally, we want to make the model available to be one of the many selected in collection b without affecting it's select one status from "collection a".

Thanks for considering.
Justin

[Question] Get current running total of items clicked

How to use this repo to get current number of items selected in dropdown and disable, say if 20 threshold is exceeded?

i.e Modal defaults to blank then as user clicks will show:

Selected 1 of 20 selected
Selected 2 of 20 selected
Selected 20 of 20 selected etc

one more click:

Cannot exceed 20 and also disables click until unless than threshold

backbone.select incompatible with Backbone.Collection initialize with {parse:true}

Although not really documented (I had to go to the source code to verify) a Backbone.Collection will let you initialize a collection with an object that may not be an array of models with the {parse:true} option. Backbone will then call the parse function on the object passed in, which can convert the object passed in to an array of models. However backbone.select requires the 'models' passed in to be an array.

I noticed this in tests where I setup my collections with a json object that mimics my server call and then I pass that to my new collection with {parse: true}. This worked fine with backbone.picky (since the models weren't passed in to it), however it breaks backbone.select

I am able to work around it since it is in my test code, however it does seem to be an incompatibility with the Backbone API on backbone.select's part.

Does not work with backbone 1.1.2

I tried using backbone.select, but noticed it didn't function properly in my project, so I set up a bare bones example using your "introductory example", but it still doesn't work unfortunately.

I get the following in the console:

"error"
"TypeError: Cannot read property 'id' of undefined
    at http://run.jsbin.com/runner:24:58"

which points to the statement console.log( collection.selected.id );
And this console.log( m1.selected ); outputs undefined as well.

Doesn't work when selectable model doesn't descend directly from Backbone.Model

I'm using another library Supermodel.js and this provides it's own module that inherits from Backbone.Model. The check for the model type: model instanceof Backbone.Model only checks the parent and not the full hierarchy. I'm wondering if there'd be another way to check the full hierarchy to see if the model descends from Backbone.Model. Another solution would be to make supermodel work as a mixin similarly to backbone.select.

this.selected.select is not a function error message

Hi,

I am attempting to use the backbone.select plugin, specifically the select.one mix in. I have followed all guidelines but keep getting an error when I attempt to select a model from the collection:

model = this.collection.get(uid);
this.collection.select(model);

Uncaught TypeError: this.selected.select is not a function

The error references line 69 in the backbone.select amd distribution:

    if ( !options._processedBy[this.selected.cid] ) this.selected.select( stripLocalOptions( options ) );

The collection is empty when initialized but that should not make a difference as it has certanly been populated and reset by the time I am calling the method..

Is this a known issue or gotcha?

Thanks,
Justin

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.