Skip to content
This repository has been archived by the owner on Jul 19, 2021. It is now read-only.

Commit

Permalink
Fix instance removal (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
cshold authored Jan 30, 2017
1 parent 9774435 commit 17f65e0
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/scripts/slate/sections.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,17 @@ slate.Sections.prototype = $.extend({}, slate.Sections.prototype, {
},

_onSectionUnload: function(evt) {
this.instances = slate.utils.removeInstance(this.instances, 'id', evt.detail.sectionId);
var instance = slate.utils.findInstance(this.instances, 'id', evt.detail.sectionId);

this.instances.forEach(function(instance) {
if (typeof instance.onUnload === 'function') {
instance.onUnload(evt);
}
});
if (!instance) {
return;
}

if (typeof instance.onUnload === 'function') {
instance.onUnload(evt);
}

this.instances = slate.utils.removeInstance(this.instances, 'id', evt.detail.sectionId);
},

_onSelect: function(evt) {
Expand Down

0 comments on commit 17f65e0

Please sign in to comment.