]> _ Git - cubist_cms-back.git/commitdiff
#2843
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 27 Jun 2019 19:04:09 +0000 (21:04 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 27 Jun 2019 19:04:09 +0000 (21:04 +0200)
src/public/bunchmultiple/bunchmultiple.js
src/resources/views/fields/bunch_multiple.blade.php

index af1b3fab5be6ebcf2d7bc9278e7c0994c7b547f5..cd07fc99eaf396b23f8edb6f5a4d22ad70e5a613 100644 (file)
                 return false;
             });
 
+            this.element.on('click', '.remove', function () {
+                $this.removeItem($(this).closest('.item'));
+                return false;
+            });
+
             this.element.on('click', '.legend', function () {
                 var item = $(this).closest('.item');
                 var subform = item.find('.subform');
             });
         },
 
+        removeItem: function (item) {
+            $(item).remove();
+            if (this.element.find('.item:not(.sample)').length == 0) {
+                this.initItem();
+            }
+            this.update();
+        },
+
         initItem: function (values) {
             var collapsed = true;
             if (values === undefined) {
             if (collapsed) {
                 $(item).addClass('collapsed');
             }
-            $(".bunchmultiple__items").append($(item));
+            $(this.element).find(".bunchmultiple__items").append($(item));
             this.setValues(item, values);
 
             $(document).trigger('cubist.bunchmultiple.added');
index d3033f3bad2b3a785ef414bdf39b9d15079247ff..ce0cf546bff61c4b9e90ee07303ffe9d7f8c2753 100644 (file)
@@ -14,7 +14,7 @@ if (!is_string($value)) {
 
 ?>
 <div class="bunchmultiple col-xs-12" id="{!! $field['rand'] !!}" data-values="{{ $value }}">
-    <input type="hidden" class="hiddenfield" name="{{$field['name']}}" value=""/>
+    <input type="hidden" class="hiddenfield" name="{{$field['name']}}" value="{{ $value }}"/>
     <div class="bunchmultiple__wrapper col-xs-12">
         <div @include('crud::inc.field_wrapper_attributes') >
             <label>{!! $field['label'] !!}</label>