Sha256: 3151c886a42a9729ec826688245165489d5fe680481d10e775310a16cd7f7b3c
Contents?: true
Size: 755 Bytes
Versions: 24
Compression:
Stored size: 755 Bytes
Contents
export default class { connect() { $("[data-action='add-another']").on("click", function(event) { event.preventDefault(); var templateId = $(this).data('template-id'); var template = document.querySelector('#' + templateId); var clone = document.importNode(template.content, true); var count = $(this).closest('.form-group').find('[name="' + $(clone).find('[name]').attr('name') + '"]').length + 1; $(clone).find('[id]').each(function(index, el) { $(el).attr('id', $(el).attr('id') + '_' + String(count)); }); $(clone).find('[for]').each(function(index, el) { $(el).attr('for', $(el).attr('for') + '_' + String(count)); }); $(clone).insertBefore(this); }); } }
Version data entries
24 entries across 24 versions & 1 rubygems