From 2206168585e859d2a38c18e964f14838f1f93831 Mon Sep 17 00:00:00 2001 From: Kike Isidoro Date: Fri, 2 Nov 2018 10:15:00 +0100 Subject: [PATCH 1/2] Fix incompatibility with Django 2.1 and jQuery 3 As Django 2.1 upgrades jQuery from 2.2.3 to 3.3.1, in which the attribute selector is removed, the sortable script stopped updating the order of the elements. I have added the compatibility proposed by jQuery in its deprecation note in the documentation. --- suit/static/suit/js/suit.sortables.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/suit/static/suit/js/suit.sortables.js b/suit/static/suit/js/suit.sortables.js index 4953ed6e..9e7c3074 100644 --- a/suit/static/suit/js/suit.sortables.js +++ b/suit/static/suit/js/suit.sortables.js @@ -2,7 +2,7 @@ * List sortables */ (function ($) { - $.fn.suit_list_sortable = function () { + $.fn.suit_list_sortable = function (selector) { var $inputs = $(this); if (!$inputs.length) return; @@ -137,7 +137,6 @@ // Update input count right before submit if ($inputs && $inputs.length) { var $last_input = $inputs.last(); - var selector = $(this).selector; $($last_input[0].form).submit(function (e) { var i = 0, value; // e.preventDefault(); @@ -172,7 +171,7 @@ $(function () { - $('.suit-sortable').suit_list_sortable(); + $('.suit-sortable').suit_list_sortable('.suit-sortable'); }); }(django.jQuery)); From b038e9bd490755bf280b674bab0b13d8bdb4bdd2 Mon Sep 17 00:00:00 2001 From: mongkok Date: Tue, 9 Apr 2019 18:31:17 +0700 Subject: [PATCH 2/2] Add jquery JS dependency --- suit/sortables.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/suit/sortables.py b/suit/sortables.py index 5b3adbc3..95048b3b 100644 --- a/suit/sortables.py +++ b/suit/sortables.py @@ -13,7 +13,7 @@ class SortableModelAdminBase(object): sortable = 'order' class Media: - js = ('suit/js/suit.sortables.js',) + js = ('admin/js/jquery.init.js', 'suit/js/suit.sortables.js') class SortableListForm(ModelForm):