diff --git a/boards/static/js/thread_update.js b/boards/static/js/thread_update.js --- a/boards/static/js/thread_update.js +++ b/boards/static/js/thread_update.js @@ -217,9 +217,34 @@ function resetForm(form) { form.find('input:text, input:password, input:file, select, textarea').val(''); form.find('input:radio, input:checkbox') .removeAttr('checked').removeAttr('selected'); - $('#file_wrap').find('#file-thumb').remove(); + $('.file_wrap').find('.file-thumb').remove(); } +/** + * When the form is posted, this method will be run as a callback + */ +function updateOnPost(response, statusText, xhr, form) { + var json = $.parseJSON(response); + var status = json.status; + + form.children('.form-errors').remove(); + + if (status === 'ok') { + resetForm(form); + updateThread(); + } else { + var errors = json.errors; + for (var i = 0; i < errors.length; i++) { + var fieldErrors = errors[i]; + + var error = fieldErrors.errors; + + var errorList = $('