-
Notifications
You must be signed in to change notification settings - Fork 177
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
Conversation
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+'[*]' : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the [*]
for?
There was a problem hiding this comment.
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.
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). |
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. |
@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. |
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? |
Running into this issue as well. Would love to be able to use these libs together more easily! |
@chiplay Are you still using a fork? Any chance you can update this PR for the latest version? |
@theoephraim here is our latest version: https://gist.github.com/chiplay/73ff365e406516bdf231 |
For use cases where you're binding to an attribute that is a Collection instance (libraries like Backbone Associations, Relational, Deep Model, etc)