Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attribute vs member #7

Open
paultyng opened this issue Jun 9, 2013 · 1 comment
Open

Attribute vs member #7

paultyng opened this issue Jun 9, 2013 · 1 comment

Comments

@paultyng
Copy link

paultyng commented Jun 9, 2013

The docs for this seem to say it will change a "selected" attribute on the model but it seems to only set a member on that instance instead of in the attributes collection via set.

On Backbone.Picky.Selectable:

    select: function () {
      if (this.selected) { return; }

      **this.selected = true;**
      this.trigger("selected");

      if (this.collection) {
        this.collection.select(this);
      }
    },

Is this intentional? I have to override my view serialization to render to pass this every time, so seems undesirable, but maybe I'm missing something?

Is this so that a change event isn't also fired or something? I guess on a fetch you would lose the selection state as well, but that could be handled.

@AdrianRossouw
Copy link

it seems that this is by design. it might also be a bit much of an assumption to make, that the model is automatically selected for anybody who loads it.

perhaps you can just subscribe to the 'select' event to set an attribute on the model, and on fetch or reset of the model, trigger the relevant select on the collection.

hashchange added a commit to hashchange/backbone.picky that referenced this issue Jan 14, 2014
hashchange added a commit to hashchange/backbone.picky that referenced this issue Jan 15, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants