-
Notifications
You must be signed in to change notification settings - Fork 83
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
Avoiding to checkchanges on sub Backbone.Models/Collections #139
base: master
Are you sure you want to change the base?
Conversation
f2cf6c9
to
cc6e2b8
Compare
Hmmmmm. The code looks good (thanks for all the documentation), but I'm wondering if there are other implications for why we wouldn't want to do this. If the object is a Model/Collection, should we be subscribing to its |
…sted Backbone.Model when we use Backbone.NestedModel
…it will generate lots of useless observers, particularly on Backbone.Model._events which may contain huge event binding data
cc6e2b8
to
1804ae6
Compare
Yep, to my POV it would be the way to go because in any other way, it would be misleading for the developper. If we bind changes on root models, direct changes on submodels won't be triggered :
On the contrary, if we bind changes to submodel, a change on the root model won't trigger it either :
=> I think this may lead to unwanted paths to be able to bind changes on submodels through rootModel (and vice versa). And I'm not even talking about performance here because you know, it's obvious that registering observers on things like |
Is there anything I can do to clear things out if there are still things unclear ? :) |
As I am using backbone-nested with Backbone.Form & Backbone.Relational it can sometimes take up to half a min to render the form with a model containing nested Models/Collection because of those listeners. (cf screenshot, yes I have commented out the line manually). |
While using Backbone.ModelBinder in correlation to backbone-nested, I encountered some weird chrome errors :
When I investigated further, I saw that
backbone-nested
was generating lots ofcheckChanges()
calls due to paths looking like :myrootmodel.attributes.mysubcollection.models.0.attributes.mysubsubcollection.models.0._events.change:anAttribute.0.context.view.regionManager._regions.MyRegion.$el.prevObject.0.lastElementChild.lastElementChild.lastElementChild.contentWindow
It was 1 of these calls which was calling an unauthorized call (from a chrome POV) on
HTMLInputElement
.To fix this issue, I propose to avoid calling
checkChanges()
on nested objects of typeBackbone.Model
orBackbone.Collection
: it seems reasonable to me since it will avoid to declare a huge amount of watchers on complexBackbone.Model
hierarchy.WDYT ?