Skip to content

Instantly share code, notes, and snippets.

@pifantastic
Forked from anonymous/gist:2295834
Created April 3, 2012 22:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pifantastic/2295860 to your computer and use it in GitHub Desktop.
Save pifantastic/2295860 to your computer and use it in GitHub Desktop.
@resetInputsForForm: (form_html, taskNumber, taskType) ->
form = $(form_html)
form.find('input').each (index, element) ->
taskNamePrefix = "#{taskType}_task"
currentName = $(element).attr('name')
multipleParamNamePrefix = "inputs_for_task['#{taskNumber}']"
newName = currentName.replace(taskNamePrefix, multipleParamNamePrefix)
$(element).attr('name', newName)
form
# pseudo
@ajaxMethod: () ->
# call resetInputsForForm, append result to a wrapper
# div which then gets appended into viewport div in the DOM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment