From 9979b50848ce27730f880159512933e50d5ae0e4 Mon Sep 17 00:00:00 2001 From: jessib Date: Wed, 3 Jul 2013 15:15:50 -0700 Subject: Automatically clear the errors when re-displayed. Not sure if this is ideal functionality. --- users/app/assets/javascripts/users.js.coffee | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'users/app/assets') diff --git a/users/app/assets/javascripts/users.js.coffee b/users/app/assets/javascripts/users.js.coffee index b0b624c..c9cc182 100644 --- a/users/app/assets/javascripts/users.js.coffee +++ b/users/app/assets/javascripts/users.js.coffee @@ -19,12 +19,16 @@ srp.error = (message) -> alert(message) display_errors = (errors) -> + clear_errors(); for field, error of errors if field == 'base' display_base_error(error); else display_field_error(field, error); +clear_errors = -> + $('#messages').empty(); + display_field_error = (field, error) -> element = $('form input[name$="['+field+']"]') return unless element @@ -32,8 +36,7 @@ display_field_error = (field, error) -> display_base_error = (message) -> messages = $('#messages') - messages.append "
×
" + message + "
" - + messages.append "
" + message + "
" pollUsers = (query, process) -> $.get( "/users.json", query: query).done(process) -- cgit v1.2.3