Skip to content

Instantly share code, notes, and snippets.

@mb-dev
Created April 3, 2013 21:54
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 mb-dev/5305779 to your computer and use it in GitHub Desktop.
Save mb-dev/5305779 to your computer and use it in GitHub Desktop.
Simple Form error rendering
form_prefix = 'chapter'
@activeView.$el.find('.help-inline').remove()
@activeView.$el.find('.control-group').removeClass('error')
if(data.errors and data.errors.messages and _(data.errors.messages).keys().length > 0)
_(data.errors.messages).each (value, key, list) =>
@activeView.$el.find('#' + form_prefix + '_' + key).closest('.control-group').addClass('error')
$('<span class="help-inline">' + value + '</span>').insertAfter(@activeView.$el.find('#' + form_prefix + '_' + key))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment