Show More
@@ -217,9 +217,34 b' function resetForm(form) {' | |||
|
217 | 217 | form.find('input:text, input:password, input:file, select, textarea').val(''); |
|
218 | 218 | form.find('input:radio, input:checkbox') |
|
219 | 219 | .removeAttr('checked').removeAttr('selected'); |
|
220 |
$(' |
|
|
220 | $('.file_wrap').find('.file-thumb').remove(); | |
|
221 | 221 | } |
|
222 | 222 | |
|
223 | /** | |
|
224 | * When the form is posted, this method will be run as a callback | |
|
225 | */ | |
|
226 | function updateOnPost(response, statusText, xhr, form) { | |
|
227 | var json = $.parseJSON(response); | |
|
228 | var status = json.status; | |
|
229 | ||
|
230 | form.children('.form-errors').remove(); | |
|
231 | ||
|
232 | if (status === 'ok') { | |
|
233 | resetForm(form); | |
|
234 | updateThread(); | |
|
235 | } else { | |
|
236 | var errors = json.errors; | |
|
237 | for (var i = 0; i < errors.length; i++) { | |
|
238 | var fieldErrors = errors[i]; | |
|
239 | ||
|
240 | var error = fieldErrors.errors; | |
|
241 | ||
|
242 | var errorList = $('<div class="form-errors">' + error | |
|
243 | + '<div>'); | |
|
244 | errorList.appendTo(form); | |
|
245 | } | |
|
246 | } | |
|
247 | } | |
|
223 | 248 | |
|
224 | 249 | $(document).ready(function(){ |
|
225 | 250 | initAutoupdate(); |
@@ -228,33 +253,13 b' function resetForm(form) {' | |||
|
228 | 253 | var threadId = $('div.thread').children('.post').first().attr('id');; |
|
229 | 254 | |
|
230 | 255 | var form = $('#form'); |
|
256 | ||
|
231 | 257 | var options = { |
|
232 | 258 | success: updateOnPost, |
|
233 |
url: '/api/add_post/' + threadId + '/' |
|
|
259 | url: '/api/add_post/' + threadId + '/' | |
|
234 | 260 | }; |
|
235 | 261 | |
|
236 | 262 | form.ajaxForm(options); |
|
237 | 263 | |
|
238 | function updateOnPost(response, statusText, xhr, $form) { | |
|
239 | var json = $.parseJSON(response); | |
|
240 | var status = json.status; | |
|
241 | ||
|
242 | form.children('.form-errors').remove(); | |
|
243 | ||
|
244 | if (status === 'ok') { | |
|
245 | resetForm(form); | |
|
246 | updateThread(); | |
|
247 | } else { | |
|
248 | var errors = json.errors; | |
|
249 | for (var i = 0; i < errors.length; i++) { | |
|
250 | var fieldErrors = errors[i]; | |
|
251 | ||
|
252 | var error = fieldErrors.errors; | |
|
253 | ||
|
254 | var errorList = $('<div class="form-errors">' + error | |
|
255 | + '<div>'); | |
|
256 | errorList.appendTo(form); | |
|
257 | } | |
|
258 | } | |
|
259 | } | |
|
264 | resetForm(form); | |
|
260 | 265 | }); |
General Comments 0
You need to be logged in to leave comments.
Login now