-
Notifications
You must be signed in to change notification settings - Fork 106
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
Global Change Event #57
Comments
I like the idea of a global change event, but it might get tricky for your binding code if you receive successive change events. For instance, if you have, say 2, sync partials on the page for the same model, if that model pushed out an update, you would receive 2 global change events back-to-back. If you're expecting this, it might not be an issue, but I could see with a heavily sync'd page, a global change event possibly becoming contextless. That said, I still think it is probably worth having, but have you considered rolling this on your own with a IE: class Sync.ChangeEmitterView extends Sync.View
afterUpdate: -> $(document).trigger("sync:update", $el: @$el, name: @name)
afterInsert: -> $(document).trigger("sync:insert", $el: @$el, name: @name)
afterRemove: -> $(document).trigger("sync:remove", $el: @$el, name: @name)
class YourModelPartial extends Sync.ChangeEmitterView thoughts? |
It's definitely something I could do on my own with the provided way to customize the JavaScript interactions, but I figured it would be a common enough use-case to build into sync itself. |
👍 this is very common IMO. |
At this point, I'd be more than happy to help review a PR for this feature, especially if addresses @chrismccord's concerns about multiple events being fired in succession. |
With the right docs, I think the change event handling is fine. |
I wrote some custom javascript that runs calculations and total from rows that are rendered in sync, and I need to re-run the calculations when anything on the page changes. I hooked into jQuery's global
ajaxComplete
to update the calculations for my own AJAX stuff, but I am not finding any kind of similar globalsyncUpdate
, etc. event to listen on for changes to the page from sync. Is there a way this can be added? Like some type of event fired ondocument
that I can listen to for anytime a row is added, updated, or deleted with sync?The text was updated successfully, but these errors were encountered: