Skip to content

Commit

Permalink
Fix jstree plugin to work with jQuery > 1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
avoinea committed Jul 20, 2016
1 parent 3b76edd commit 596ccc2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
4 changes: 3 additions & 1 deletion docs/HISTORY.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Changelog

9.1.dev0 - (unreleased)
-----------------------
* Bug fix: Fixed jstree plugin by replacing deprecated jQuery `.live` with `.on`
[avoinea]

9.0 - (2016-06-29)
------------------
Expand All @@ -20,7 +22,7 @@ Changelog

8.8 - (2016-03-31)
------------------
* Bug fix: use applyPrefix=1 for the select2 CSS registration so images like
* Bug fix: use applyPrefix=1 for the select2 CSS registration so images like
select2.png are found correctly.
[gbastien]

Expand Down
18 changes: 9 additions & 9 deletions eea/jquery/plugins/jstree/jquery.tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,17 +392,17 @@ reselect : function (is_callback) {
//event.stopPropagation();
return true;
});
$("#" + this.container.attr("id") + " li")
.live("click", function(event) { // WHEN CLICK IS ON THE ARROW
this.container
.on("click", 'li', function(event) { // WHEN CLICK IS ON THE ARROW
if(event.target.tagName != "LI") return true;
_this.off_height();
if(event.pageY - $(event.target).offset().top > _this.li_height) return true;
_this.toggle_branch.apply(_this, [event.target]);
event.stopPropagation();
return false;
});
$("#" + this.container.attr("id") + " li a")
.live("click.jstree", function (event) { // WHEN CLICK IS ON THE TEXT OR ICON
this.container
.on("click.jstree", "li a", function (event) { // WHEN CLICK IS ON THE TEXT OR ICON
if(event.which && event.which == 3) return true;
if(_this.locked) {
event.preventDefault();
Expand All @@ -415,7 +415,7 @@ reselect : function (is_callback) {
event.target.blur();
return false;
})
.live("dblclick.jstree", function (event) { // WHEN DOUBLECLICK ON TEXT OR ICON
.on("dblclick.jstree", "li a", function (event) { // WHEN DOUBLECLICK ON TEXT OR ICON
if(_this.locked) {
event.preventDefault();
event.stopPropagation();
Expand All @@ -427,14 +427,14 @@ reselect : function (is_callback) {
event.stopPropagation();
event.target.blur();
})
.live("contextmenu.jstree", function (event) {
.on("contextmenu.jstree", "li a", function (event) {
if(_this.locked) {
event.target.blur();
return _this.error("LOCKED");
}
return _this.callback("onrgtclk", [_this.get_node(event.target).get(0), _this, event]);
})
.live("mouseover.jstree", function (event) {
.on("mouseover.jstree", "li a", function (event) {
if(_this.locked) {
event.preventDefault();
event.stopPropagation();
Expand All @@ -446,7 +446,7 @@ reselect : function (is_callback) {
}
_this.callback("onhover",[_this.get_node(event.target).get(0), _this]);
})
.live("mousedown.jstree", function (event) {
.on("mousedown.jstree", "li a", function (event) {
if(_this.settings.rules.drag_button == "left" && event.which && event.which != 1) return true;
if(_this.settings.rules.drag_button == "right" && event.which && event.which != 3) return true;
_this.focus.apply(_this);
Expand Down Expand Up @@ -2055,4 +2055,4 @@ load : function(data, tree, opts, callback) {
}
}
});
})(jQuery);
})(jQuery);

0 comments on commit 596ccc2

Please sign in to comment.