Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Store bindings in each view, instead of a globally shared array #8

Merged
merged 1 commit into from

2 participants

@KidkArolis

Previously, the _modelBindings array was shared among all views, which means when one view is destroyed, all of the bindings in all views are lost.

Should I provide tests reproducing the problem?

@delambo delambo merged commit 66ad734 into NYTimes:master
@delambo
Owner

@KidkArolis Thanks! I think this cleans up the multi-view use-case that I hacked into issue #4.

@delambo
Owner

@KidkArolis Heads up - I just committed an additional fix for this to master (the case when multiple models are initialized by calling stickit again).

@KidkArolis

Good stuff :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 1 deletion.
  1. +3 −1 backbone.stickit.js
View
4 backbone.stickit.js
@@ -9,7 +9,7 @@
// Collection of model event bindings.
// [{model,event,fn}, ...]
- _modelBindings: [],
+ _modelBindings: null,
// Unbind the model bindings that are referenced in `this._modelBindings`.
unstickModel: function() {
@@ -26,6 +26,8 @@
model = optionalModel || this.model,
bindings = optionalBindingsConfig || this.bindings || {};
+ this._modelBindings = [];
+
this.events || (this.events = {});
// Setup a model event binding with the given function, and track the event in this._modelBindings.
Something went wrong with that request. Please try again.