From 7ba759e77b59846f7c149720f39ed343d22abab7 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Thu, 14 Jun 2012 18:11:51 +0200 Subject: [PATCH] MINOR Fixed jQuery.jstree men leaks on 'dnd' and 'context menu' plugins, by removing globally bound event handlers (see #7258) --- thirdparty/jstree/jquery.jstree.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/thirdparty/jstree/jquery.jstree.js b/thirdparty/jstree/jquery.jstree.js index 968d48cd7..40a7e31cc 100644 --- a/thirdparty/jstree/jquery.jstree.js +++ b/thirdparty/jstree/jquery.jstree.js @@ -2542,6 +2542,15 @@ drag_finish : $.noop, drag_check : function (data) { return { after : false, before : false, inside : true }; } }, + __destroy : function () { + // unbind global event handlers when last instance is removed + // (no access to private 'instances' variable from here) + if($('.jstree').length <= 1) { + $(document) + .unbind("drag_start.vakata") + .unbind("drag_stop.vakata"); + } + }, _fn : { dnd_prepare : function () { if(!r || !r.length) { return; } @@ -3719,6 +3728,13 @@ }, this)); $(document).bind("context_hide.vakata", $.proxy(function () { this.data.contextmenu = false; }, this)); }, + __destroy: function() { + // unbind global event handlers when last instance is removed + // (no access to private 'instances' variable from here) + if($('.jstree').length <= 1) { + $(document).unbind("context_hide.vakata"); + } + }, defaults : { select_node : false, // requires UI plugin show_at_node : true,