diff --git a/javascript/LeftAndMain.EditForm.js b/javascript/LeftAndMain.EditForm.js index 1f8517a3..6739a00b 100644 --- a/javascript/LeftAndMain.EditForm.js +++ b/javascript/LeftAndMain.EditForm.js @@ -57,20 +57,21 @@ } // get all data from the form - var data = this.serializeArray(); + var formData = this.serializeArray(); // add button action - data.push({name: $(button).attr('name'), value:'1'}); - $.post( - this.attr('action'), - data, - function(response) { + formData.push({name: $(button).attr('name'), value:'1'}); + + $.ajax({ + url: this.attr('action'), + data: formData, + type: 'POST', + complete: function(xmlhttp, status) { $(button).removeClass('loading'); - - self._loadResponse(response); + // pass along original form data to enable old/new comparisons + self._loadResponse(xmlhttp.responseText, status, xmlhttp, formData); }, - // @todo Currently all responses are assumed to be evaluated - 'script' - ); + dataType: 'html' + }); return false; }, @@ -96,15 +97,14 @@ */ load: function(url, callback) { var self = this; - $.get( - url, - function(response) { - self._loadResponse(response); - if(callback) callback.apply(self, [response]); + $.ajax({ + url: url, + complete: function(xmlhttp, status) { + self._loadResponse(xmlhttp.responseText, status, xmlhttp); + if(callback) callback.apply(self, arguments); }, - // @todo Currently all responses are assumed to be evaluated - 'script' - ); + dataType: 'html' + }); }, /** @@ -114,7 +114,8 @@ * @param {String} removeText Short note why the form has been removed, displayed in
tags. * Falls back to the default RemoveText() option (Optional) */ - remove: function(removeText) { + removeForm: function(removeText) { + if(!removeText) removeText = this.RemoveText(); this.html('
' + removeText + '
'); }, @@ -133,49 +134,65 @@ }, /** - * @param {String} result Either HTML for straight insertion, or eval'ed JavaScript. + * @param {String} data Either HTML for straight insertion, or eval'ed JavaScript. * If passed as HTML, it is assumed that everying inside the