Skip to content

Instantly share code, notes, and snippets.

@j
Created August 1, 2011 20:29
Show Gist options
  • Save j/1118915 to your computer and use it in GitHub Desktop.
Save j/1118915 to your computer and use it in GitHub Desktop.
$('div.collection div.add a').click(function() {
var $parent = $(this).parent().parent(), $prototype = $parent.find('div:first div:last'), html;
html = $prototype.attr('data-prototype').replace(/\$\$name\$\$/g, $parent.find('div:first > div:not(:last)').length);
$prototype.before(html);
return false;
});
<div class="collection">
{{ form_row(form.parameters) }}
<div class="add">
<a style="float: right;" href="#" title="Add">Add</a>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment