From 7a6329dded3d2183017600c9279ae088d6f197ad Mon Sep 17 00:00:00 2001 From: brisksystems-us <101900157+brisksystems-us@users.noreply.github.com> Date: Thu, 2 Nov 2023 00:55:23 -0500 Subject: [PATCH] Improve compatibility with Jquery >= 3.0 Replace incompatible jquery-ui 'position' function call with native Javascript to allow using newer versions of Jquery (Tested on Jquery 3.4) --- .../static/selectable/js/jquery.dj.selectable.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/selectable/static/selectable/js/jquery.dj.selectable.js b/selectable/static/selectable/js/jquery.dj.selectable.js index 7555a41..ab4bd35 100644 --- a/selectable/static/selectable/js/jquery.dj.selectable.js +++ b/selectable/static/selectable/js/jquery.dj.selectable.js @@ -12,6 +12,18 @@ * BSD License * */ +function positionDropdown(input, ul) { + //Given an input element and a ul, positions the ul dropdown appropriately + //Uses native javascript where necessary to fix compatibility with Jquery 3.0 and newer + var selectRect = document.getElementById($(input.element[0]).attr('id')).getBoundingClientRect(); + //Account for scrollbar position + var left = parseFloat(selectRect.left) + parseFloat(window.scrollX); + var top = parseFloat(selectRect.bottom) + parseFloat(window.scrollY); + //Use element style attribute to set the position + var style = $(ul).attr('style')+ 'left:'+left+'px;' + 'top: '+top+'px;'; + $(ul).attr('style', style); +} + (function ($) { $.widget("ui.djselectable", $.ui.autocomplete, { @@ -278,7 +290,8 @@ // size and position menu ul.show(); this._resizeMenu(); - ul.position($.extend({of: this.element}, this.options.position)); + positionDropdown(this, ul); //Call function that uses native Javascript + //ul.position($.extend/({of: $(this).element}, $(this).position)); if (this.options.autoFocus) { this.menu.next(new $.Event("mouseover")); } else if (page) {