Skip to content

Instantly share code, notes, and snippets.

@rewinfrey
Created April 18, 2013 20:21
Show Gist options
  • Save rewinfrey/5415906 to your computer and use it in GitHub Desktop.
Save rewinfrey/5415906 to your computer and use it in GitHub Desktop.
watbro.coffee from myles
@buildForm: (options) ->
form = $("<form></form>")
form.attr('method', options.method)
form.attr('action', options.action)
form.attr('target', options.target)
csrf_token = $('meta[name=csrf-token]').attr('content')
csrf_param = $('meta[name=csrf-param]').attr('content')
options[csrf_param] = csrf_token
for key, value of options.params
input = $('<input></input>')
input.attr('name', key)
input.attr('value', value)
form.append(input)
form
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment