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

Update event listeners to work with Backbone Collections #230

Closed
wants to merge 1 commit into from

Conversation

chiplay
Copy link
Contributor

@chiplay chiplay commented Apr 22, 2014

For use cases where you're binding to an attribute that is a Collection instance (libraries like Backbone Associations, Relational, Deep Model, etc)

@chiplay
Copy link
Contributor Author

chiplay commented Apr 22, 2014

Discussion from the original PR: #180

var observeModelEvent = function(model, view, attr, config, fn) {
// Detect attr type for Backbone Collections
var event = (model.get(attr) instanceof Backbone.Collection) ?
'add:'+attr+' remove:'+attr+' reset:'+attr+' change:'+attr+'[*]' :
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the [*] for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its specific to the event graph for backbone associations: http://dhruvaray.github.io/backbone-associations/events.html It means an event will fire anytime ANY attribute changes on any of the models in that collection. Not sure how other nested model libs deal with this, but its a nice feature.

@akre54
Copy link
Contributor

akre54 commented Apr 22, 2014

Urgh. Is there a way we can maybe extract this so you can override it in your own project? I dont like the idea of having to support all of these different libraries (which IMO promote bad patterns).

@chiplay
Copy link
Contributor Author

chiplay commented Apr 22, 2014

Sure thing. I'm not 100% that we are even still relying on it for our app. Standard add, remove, reset (and possible sort) events certainly make more sense.

@chiplay
Copy link
Contributor Author

chiplay commented Apr 22, 2014

@akre54 woops - sorry about that, thought your last comment was specific to the [*] bit, but I believe your talking about the whole PR. I'm totally fine with this not going in, we've got several other small variations we've done to stickit that probably wont make the cut, so using a forked version isn't an issue. There we're others interested, so I figured I'd clean up the old PR just incase.

@akre54
Copy link
Contributor

akre54 commented May 1, 2014

I don't like the idea of adding support for nested libraries but I'm open to making them easier to work with in StickIt. Is there a less invasive change to Stickit that would allow you to make it work with your own app?

@theoephraim
Copy link

Running into this issue as well. Would love to be able to use these libs together more easily!

@theoephraim
Copy link

@chiplay Are you still using a fork? Any chance you can update this PR for the latest version?

@chiplay
Copy link
Contributor Author

chiplay commented May 8, 2015

@theoephraim here is our latest version: https://gist.github.com/chiplay/73ff365e406516bdf231

@chiplay chiplay closed this Sep 6, 2018
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

Successfully merging this pull request may close these issues.

3 participants