Skip to content

Instantly share code, notes, and snippets.

@pete-a
Created March 23, 2015 05:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pete-a/248f16c387171495a04c to your computer and use it in GitHub Desktop.
Save pete-a/248f16c387171495a04c to your computer and use it in GitHub Desktop.
duplicate_fields = (url) ->
if $('.duplicatable_nested_form').length == 1 && (typeof $('#upload_content_location').attr('value') == 'undefined')
$('#upload_content_location').attr('value', url)
return
if $('.duplicatable_nested_form').length > 0
lastNestedForm = $('.duplicatable_nested_form').last()
nestedForm = $('.duplicatable_nested_form').last().clone()
update_clone_block(nestedForm[0], url)
$( nestedForm ).insertAfter( lastNestedForm )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment