Skip to content
This repository
Browse code

MINOR Fixed jQuery.jstree men leaks on 'dnd' and 'context menu' plugi…

…ns, by removing globally bound event handlers (see #7258)
  • Loading branch information...
commit 7ba759e77b59846f7c149720f39ed343d22abab7 1 parent 5260738
Ingo Schommer authored June 14, 2012

Showing 1 changed file with 16 additions and 0 deletions. Show diff stats Hide diff stats

  1. 16  thirdparty/jstree/jquery.jstree.js
16  thirdparty/jstree/jquery.jstree.js
@@ -2542,6 +2542,15 @@
2542 2542
 			drag_finish		: $.noop,
2543 2543
 			drag_check		: function (data) { return { after : false, before : false, inside : true }; }
2544 2544
 		},
  2545
+		__destroy : function () {
  2546
+			// unbind global event handlers when last instance is removed
  2547
+			// (no access to private 'instances' variable from here)
  2548
+			if($('.jstree').length <= 1) {
  2549
+				$(document)
  2550
+					.unbind("drag_start.vakata")
  2551
+					.unbind("drag_stop.vakata");	
  2552
+			}
  2553
+		},
2545 2554
 		_fn : {
2546 2555
 			dnd_prepare : function () {
2547 2556
 				if(!r || !r.length) { return; }
@@ -3719,6 +3728,13 @@
3719 3728
 					}, this));
3720 3729
 			$(document).bind("context_hide.vakata", $.proxy(function () { this.data.contextmenu = false; }, this));
3721 3730
 		},
  3731
+		__destroy: function() {
  3732
+			// unbind global event handlers when last instance is removed
  3733
+			// (no access to private 'instances' variable from here)
  3734
+			if($('.jstree').length <= 1) {
  3735
+				$(document).unbind("context_hide.vakata");	
  3736
+			}
  3737
+		},
3722 3738
 		defaults : { 
3723 3739
 			select_node : false, // requires UI plugin
3724 3740
 			show_at_node : true,

0 notes on commit 7ba759e

Please sign in to comment.
Something went wrong with that request. Please try again.