From: Vincent Vanwaelscappel Date: Thu, 27 Jun 2019 19:04:09 +0000 (+0200) Subject: #2843 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=bcc8665bb576829cdebbc5f119439cd0cc0113f7;p=cubist_cms-back.git #2843 --- diff --git a/src/public/bunchmultiple/bunchmultiple.js b/src/public/bunchmultiple/bunchmultiple.js index af1b3fa..cd07fc9 100644 --- a/src/public/bunchmultiple/bunchmultiple.js +++ b/src/public/bunchmultiple/bunchmultiple.js @@ -22,6 +22,11 @@ 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'); @@ -105,6 +110,14 @@ }); }, + 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) { @@ -116,7 +129,7 @@ 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'); diff --git a/src/resources/views/fields/bunch_multiple.blade.php b/src/resources/views/fields/bunch_multiple.blade.php index d3033f3..ce0cf54 100644 --- a/src/resources/views/fields/bunch_multiple.blade.php +++ b/src/resources/views/fields/bunch_multiple.blade.php @@ -14,7 +14,7 @@ if (!is_string($value)) { ?>
- +