diff options
author | jessib <jessib@leap.se> | 2013-07-03 15:15:50 -0700 |
---|---|---|
committer | jessib <jessib@leap.se> | 2013-07-03 15:15:50 -0700 |
commit | 9979b50848ce27730f880159512933e50d5ae0e4 (patch) | |
tree | 6168f5e7f45cd6a4cacf56b4db594fc7e750c71e /users/app | |
parent | a01e7686ea7c046a9cd544b618b30727f2a41b3b (diff) |
Automatically clear the errors when re-displayed. Not sure if this is ideal functionality.
Diffstat (limited to 'users/app')
-rw-r--r-- | users/app/assets/javascripts/users.js.coffee | 7 |
1 files changed, 5 insertions, 2 deletions
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 "<div class=\"alert alert-error\"><a class=\"close\" \"data-dismiss\"=\"alert\">×</a><div class=\"flash_error\">" + message + "</div></div>" - + messages.append "<div class=\"alert alert-error\">" + message + "</div></div>" pollUsers = (query, process) -> $.get( "/users.json", query: query).done(process) |