diff options
author | Robert Kowalski <rok@kowalski.gd> | 2014-05-07 20:22:36 +0200 |
---|---|---|
committer | Robert Kowalski <rok@kowalski.gd> | 2014-05-07 20:26:36 +0200 |
commit | ebade0f2f82d4da60e386f4aeaf24ecb98181e81 (patch) | |
tree | a4d9a9b3f82b82008d5cb4a248709de5f5b34754 | |
parent | 2fe69e704bf3520334082a03fcf07434eda44ea0 (diff) | |
download | couchdb-ebade0f2f82d4da60e386f4aeaf24ecb98181e81.tar.gz |
Fauxton: use .listenTo and not .on
There was no `.off` call on destroy, so these two Eventhandlers
where leaking memory
-rw-r--r-- | src/fauxton/app/addons/documents/views.js | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/fauxton/app/addons/documents/views.js b/src/fauxton/app/addons/documents/views.js index 896f19b5f..2df3ab6fb 100644 --- a/src/fauxton/app/addons/documents/views.js +++ b/src/fauxton/app/addons/documents/views.js @@ -928,7 +928,9 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, }, afterRender: function() { - var saveDoc = this.saveDoc; + var saveDoc = this.saveDoc, + editor, + model; this.editor = new Components.Editor({ editorId: "editor-container", @@ -943,12 +945,9 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, }] }); this.editor.render(); - this.model.on("sync", this.updateValues, this); - var editor = this.editor, - model = this.model; - - editor.editor.on("change", function (event) { + this.listenTo(this.model, "sync", this.updateValues); + this.listenTo(editor.editor, "change", function (event) { var changedDoc; try { changedDoc = JSON.parse(editor.getValue()); @@ -974,6 +973,9 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, clear: true }); }); + + editor = this.editor; + model = this.model; }, cleanup: function () { |