From 7c1b477731ec9ff31c5d5039879fc42e33b70613 Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Sun, 31 Aug 2008 22:41:43 +0000 Subject: [PATCH] Updated the AJAX library to remove the response DIV if it is already present (to eliminate the double message scenario). git-svn-id: http://svn.cleancode.org/svn/pickles@40 4d10bc64-7434-11dc-a737-d2d0f8310089 --- static/js/ajax.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/static/js/ajax.js b/static/js/ajax.js index 6d2ea4a..4207430 100644 --- a/static/js/ajax.js +++ b/static/js/ajax.js @@ -81,13 +81,17 @@ function ajaxSubmit(form, customHandler, beforeOrAfter) { } else { var responseMessage = document.createTextNode(responseObject.message); - responseElement.className = responseObject.type; - responseElement.appendChild(responseMessage); } + + if (document.getElementById('ajaxResponse') != null) { + form.removeChild(document.getElementById('ajaxResponse')); + } + responseElement.id = 'ajaxResponse'; form.insertBefore(responseElement, (beforeOrAfter == 'before') ? form.firstChild : form.lastChild); + } }