From 8d556539b305614a20e21470f04b22465d9aba64 Mon Sep 17 00:00:00 2001 From: Helidium Date: Mon, 31 Mar 2014 13:41:37 +0200 Subject: [PATCH] Implemented destroy for ajax use of API I don't know if the commit is implemented in the correct way, but it does remove the event listeners and the containers. Please revise and update accordingly. --- source/js/jquery-sortable.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/js/jquery-sortable.js b/source/js/jquery-sortable.js index 8c93d4d..b063745 100644 --- a/source/js/jquery-sortable.js +++ b/source/js/jquery-sortable.js @@ -431,7 +431,8 @@ destroy: function () { // TODO iterate over subgroups and destroy them // TODO remove all events - containerGroups[this.options.group] = undefined + delete containerGroups[this.options.group]; + //containerGroups[this.options.group] = undefined } } @@ -447,6 +448,8 @@ var itemPath = this.rootGroup.options.itemPath, target = itemPath ? this.el.find(itemPath) : this.el + this.target = target; + target.on(eventNames.start, this.handle, $.proxy(this.dragInit, this)) if(this.options.drop) @@ -614,6 +617,8 @@ return this._serialize(this.el, true) }, destroy: function () { + this.target.off( eventNames.start ); + this.group.containers = []; this.rootGroup.destroy() } }