app/assets/javascripts/formstrap/controllers/repeater_controller.js in formstrap-0.3.1 vs app/assets/javascripts/formstrap/controllers/repeater_controller.js in formstrap-0.3.2
- old
+ new
@@ -108,14 +108,20 @@
}
replaceIdsWithTimestamps (template) {
const pattern = 'rrrrrrrrr'
const replacement = new Date().getTime().toString()
+ const regex = new RegExp(pattern, 'g')
// Replace ids
template.querySelectorAll(`input[id*="${pattern}"], select[id*="${pattern}"], textarea[id*="${pattern}"], button[id*="${pattern}"]`).forEach((node) => {
const idValue = node.getAttribute('id')
node.setAttribute('id', idValue.replace(pattern, replacement))
+ })
+
+ // Search and replace pattern in templates
+ template.querySelectorAll('template').forEach((node) => {
+ node.innerHTML = node.innerHTML.replace(regex, replacement)
})
// Replace labels
template.querySelectorAll(`label[for*="${pattern}"]`).forEach((node) => {
const forValue = node.getAttribute('for')