Skip to content

Instantly share code, notes, and snippets.

@vmihailenco
Created July 11, 2011 09:15
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 vmihailenco/1075580 to your computer and use it in GitHub Desktop.
Save vmihailenco/1075580 to your computer and use it in GitHub Desktop.
aform.coffee
exports = exports ? @
aform = {}
exports.aform = aform
aform.render_form_errors = ($form, fieldErrors, prefix='') ->
if prefix?
prefix = prefix += '-'
for name, errors of fieldErrors
$field = $ "#id_#{prefix}#{name}"
errors = "<ol class='errors'><li>#{errors.join('</li><li>')}</li></ol>"
$field.parent().addClass 'error'
$(errors).insertBefore $field
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment