From a2f07e545f327083b1c8b70b34541ce1850702fc Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Fri, 13 Nov 2015 14:37:59 +0100 Subject: [PATCH] Fixes js button issue https://github.com/getgrav/grav-plugin-admin/issues/270 --- themes/grav/js/admin-all.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/themes/grav/js/admin-all.js b/themes/grav/js/admin-all.js index 4813db95..419577de 100644 --- a/themes/grav/js/admin-all.js +++ b/themes/grav/js/admin-all.js @@ -472,9 +472,17 @@ $(function () { newItem.attr('data-collection-item', newItem.attr('data-collection-item').replace('*', key)); newItem.attr('data-collection-key', key); - newItem.find('[name]').each(function () { - $(this).attr('name', $(this).attr('name').replace('*', key)); - }); + + var replaceAttribute = function replaceAttribute(attribute) { + newItem.find('[' + attribute + ']').each(function () { + $(this).attr(attribute, $(this).attr(attribute).replace('*', key)); + }); + }; + + replaceAttribute('name'); + replaceAttribute('data-grav-field-name'); + replaceAttribute('id'); + replaceAttribute('for'); holder.append(newItem); button.data('key-index', ++key);