Просмотр исходного кода

Fixes RelatedObjectLookups for django 1.9+

Denis K 8 лет назад
Родитель
Сommit
a2b2f65e60

+ 27 - 1
jet/static/admin/js/admin/RelatedObjectLookups.js

@@ -175,4 +175,30 @@ function showRelatedPopup(name, href) {
 function closeRelatedPopup(win) {
     jet.jQuery('select').trigger('select:init');
     jet.jQuery(win.parent).trigger('related-popup:close');
-}
+}
+
+django.jQuery(document).ready(function() {
+    jet.jQuery(function($){
+        function updateLinks() {
+            var $this = $(this);
+            var siblings = $this.nextAll('.change-related, .delete-related');
+            if (!siblings.length) return;
+            var value = $this.val();
+            if (value) {
+                siblings.each(function(){
+                    var elm = $(this);
+                    elm.attr('href', elm.attr('data-href-template').replace('__fk__', value));
+                });
+            } else siblings.removeAttr('href');
+        }
+        var container = $(document);
+        container.on('change', '.related-widget-wrapper select', updateLinks);
+        container.find('.related-widget-wrapper select').each(updateLinks);
+        container.on('click', '.related-widget-wrapper-link', function(event){
+            if (this.href) {
+                showRelatedObjectPopup(this);
+            }
+            event.preventDefault();
+        });
+    });
+});

+ 0 - 25
jet/static/admin/js/related-widget-wrapper.js

@@ -1,25 +0,0 @@
-django.jQuery(document).ready(function() {
-    jet.jQuery(function($){
-        function updateLinks() {
-            var $this = $(this);
-            var siblings = $this.nextAll('.change-related, .delete-related');
-            if (!siblings.length) return;
-            var value = $this.val();
-            if (value) {
-                siblings.each(function(){
-                    var elm = $(this);
-                    elm.attr('href', elm.attr('data-href-template').replace('__fk__', value));
-                });
-            } else siblings.removeAttr('href');
-        }
-        var container = $(document);
-        container.on('change', '.related-widget-wrapper select', updateLinks);
-        container.find('.related-widget-wrapper select').each(updateLinks);
-        container.on('click', '.related-widget-wrapper-link', function(event){
-            if (this.href) {
-                showRelatedObjectPopup(this);
-            }
-            event.preventDefault();
-        });
-    });
-});