BUGFIX Switching all ajax implementations to consistently use jQuery.ajax instead of Prototype's Ajax.Request() (AssetTableField, CommentTableField, MemberTableField, WidgetAreaEditor)

This commit is contained in:
Ingo Schommer 2011-03-02 17:15:20 +13:00
parent fd3ae9100f
commit 0e9bf073c8
4 changed files with 46 additions and 42 deletions

View File

@ -127,6 +127,7 @@ AssetTableField.prototype = {
var img = Event.element(e); var img = Event.element(e);
var link = Event.findElement(e,"a"); var link = Event.findElement(e,"a");
var row = Event.findElement(e,"tr"); var row = Event.findElement(e,"tr");
var self = this;
var linkCount = row.getElementsByClassName('linkCount')[0]; var linkCount = row.getElementsByClassName('linkCount')[0];
if(linkCount) linkCount = linkCount.innerHTML; if(linkCount) linkCount = linkCount.innerHTML;
@ -139,30 +140,28 @@ AssetTableField.prototype = {
if(confirmed) if(confirmed)
{ {
img.setAttribute("src",'cms/images/network-save.gif'); // TODO doesn't work img.setAttribute("src",'cms/images/network-save.gif'); // TODO doesn't work
new Ajax.Request( jQuery.ajax({
link.getAttribute("href"), 'url': link.getAttribute("href"),
{ 'method': 'post',
method: 'post', 'data': {'forceajax': 1, 'SecurityID': $('SecurityID') ? $('SecurityID').value : null},
postBody: 'forceajax=1' + ($('SecurityID') ? '&SecurityID=' + $('SecurityID').value : ''), 'success': function(){
onComplete: function(){ Effect.Fade(
Effect.Fade( row,
row, {
{ afterFinish: function(obj) {
afterFinish: function(obj) { // remove row from DOM
// remove row from DOM obj.element.parentNode.removeChild(obj.element);
obj.element.parentNode.removeChild(obj.element); // recalculate summary if needed (assumes that TableListField.js is present)
// recalculate summary if needed (assumes that TableListField.js is present) // TODO Proper inheritance
// TODO Proper inheritance if(self._summarise) self._summarise();
if(this._summarise) this._summarise(); // custom callback
// custom callback if(self.callback_deleteRecord) self.callback_deleteRecord(e);
if(this.callback_deleteRecord) this.callback_deleteRecord(e);
}.bind(this)
} }
); }
}.bind(this), );
onFailure: this.ajaxErrorHandler },
} 'error': this.ajaxErrorHandler
); });
} }
Event.stop(e); Event.stop(e);

View File

@ -55,17 +55,15 @@ CommentTableField.prototype = {
var row = Event.findElement(e,"tr"); var row = Event.findElement(e,"tr");
img.setAttribute("src",'cms/images/network-save.gif'); // TODO doesn't work in Firefox1.5+ img.setAttribute("src",'cms/images/network-save.gif'); // TODO doesn't work in Firefox1.5+
new Ajax.Request( jQuery.ajax({
link.getAttribute("href"), 'url': link.getAttribute("href")
{ 'method': 'post',
method: 'post', 'data': 'forceajax=1',
postBody: 'forceajax=1', 'success': function(){
onComplete: function(){ Effect.Fade(row);
Effect.Fade(row); },
}.bind(this), 'error': function(response) {errorMessage('Server Error', response);}
onFailure: function(response) {errorMessage('Server Error', response);} });
}
);
Event.stop(e); Event.stop(e);
}, },

View File

@ -341,13 +341,15 @@ function ajaxSubmitFieldSet(href, fieldSet, extraData) {
data += '&'+extraData; data += '&'+extraData;
} }
// Send request // Send request
new Ajax.Request(href, { jQuery.ajax({
method : 'post', postBody : data, 'url': href,
onSuccess : function(response) { 'method' : 'post',
'data' : data,
'success' : function(response) {
//alert(response.responseText); //alert(response.responseText);
Ajax.Evaluator(response); Ajax.Evaluator(response);
}, },
onFailure : function(response) { 'error' : function(response) {
alert(response.responseText); alert(response.responseText);
//errorMessage('Error: ', response); //errorMessage('Error: ', response);
} }

View File

@ -122,12 +122,14 @@ WidgetAreaEditorClass.prototype = {
this.name = holder; this.name = holder;
new Ajax.Request('Widget_Controller/EditableSegment/' + className, { jQuery.ajax({
onSuccess : $('usedWidgets-'+holder).parentNode.parentNode.insertWidgetEditor.bind(this) 'url': 'Widget_Controller/EditableSegment/' + className,
'success' : $('usedWidgets-'+holder).parentNode.parentNode.insertWidgetEditor.bind(this)
}); });
}, },
updateWidgets: function() { updateWidgets: function() {
var self = this;
// Gotta get the name of the current dohickey based off the ID // Gotta get the name of the current dohickey based off the ID
this.name = this.element.id.split('-').pop(); this.name = this.element.id.split('-').pop();
@ -149,8 +151,11 @@ WidgetAreaEditorClass.prototype = {
var wIdArray = widget.id.split('-'); var wIdArray = widget.id.split('-');
wIdArray.pop(); wIdArray.pop();
new Ajax.Request('Widget_Controller/EditableSegment/' + wIdArray.join('-'), { jQuery.ajax({
onSuccess : $('usedWidgets-'+this.name).parentNode.parentNode.insertWidgetEditor.bind(this) 'url': 'Widget_Controller/EditableSegment/' + wIdArray.join('-'),
'success' : function() {
$('usedWidgets-'+self.name).parentNode.parentNode.insertWidgetEditor();
}
}); });
} }
} }