]> _ Git - cubist_cms-back.git/commitdiff
wip #5301 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 31 May 2022 11:51:30 +0000 (13:51 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 31 May 2022 11:51:30 +0000 (13:51 +0200)
src/public/bunchmultiple/bunchmultiple.js

index 1d0a03deb0d9ec1097070abf356a449aa87d2ef3..dc8f4321fdf3cc9d6afdf327ded1cdff8d036ae8 100644 (file)
                 return false;
             });
 
-            this.element.on('change', 'input' + this.bmidselector +
-                ',select' + this.bmidselector +
-                ',textarea' + this.bmidselector +
-                ',.dropzone' + this.bmidselector, function () {
+            this.element.on('change', 'input' + this.bmidselector + ',select' + this.bmidselector + ',textarea' + this.bmidselector + ',.dropzone' + this.bmidselector, function () {
                 $this.updateAndChange();
                 return true;
             });
 
             }, 1000);
             this.resize();
+
+            setInterval(function () {
+                $this.serialize();
+            }, 2000);
         },
 
         cleanTemplate: function () {
         },
 
         serialize: function () {
-
-
             var val = [];
             var $this = this;
             var id = this.element.attr('id');
-            $.each(this.element.find('.item' + this.bmidselector + ':not(.sample) .bunchfields' + this.bmidselector), function () {
+            var selector = '.item' + this.bmidselector + ':not(.sample) ' + this.bmidselector + ' .bunchfields';
+            var list = this.element.find(selector);
+
+            $.each(list, function () {
                 $(this).find('.bunchmultiple').each(function () {
                     try {
                         $(this).data('bunchmultiple').serialize();
             var $this = this;
 
             new Sortable(this.element.find('.bunchmultiple__items' + this.bmidselector).get(0), {
-                handle: '.sort-handle',
-                ghostClass: 'ghost',
-                onSort: function (evt) {
+                handle: '.sort-handle', ghostClass: 'ghost', onSort: function (evt) {
                     $this.onSort(evt);
                 },
             });
@@ -301,9 +301,7 @@ jQuery.cachedScript = function (url, options) {
 
     // Allow user to set any option except for dataType, cache, and url
     options = $.extend(options || {}, {
-        dataType: "script",
-        cache: true,
-        url: url
+        dataType: "script", cache: true, url: url
     });
 
     // Use $.ajax() since it is more flexible than $.getScript