Permalink
Browse files

BUGFIX Switching all ajax implementations to consistently use jQuery.…

…ajax instead of Prototype's Ajax.Request() (AssetTableField, CommentTableField, MemberTableField, WidgetAreaEditor)
  • Loading branch information...
chillu committed Mar 2, 2011
1 parent fd3ae91 commit 0e9bf073c8f0080c552bd511dfc64b2c965fadd7
Showing with 46 additions and 42 deletions.
  1. +22 −23 javascript/AssetTableField.js
  2. +9 −11 javascript/CommentTableField.js
  3. +6 −4 javascript/MemberTableField.js
  4. +9 −4 javascript/WidgetAreaEditor.js
@@ -127,6 +127,7 @@ AssetTableField.prototype = {
var img = Event.element(e);
var link = Event.findElement(e,"a");
var row = Event.findElement(e,"tr");
+ var self = this;
var linkCount = row.getElementsByClassName('linkCount')[0];
if(linkCount) linkCount = linkCount.innerHTML;
@@ -139,30 +140,28 @@ AssetTableField.prototype = {
if(confirmed)
{
img.setAttribute("src",'cms/images/network-save.gif'); // TODO doesn't work
- new Ajax.Request(
- link.getAttribute("href"),
- {
- method: 'post',
- postBody: 'forceajax=1' + ($('SecurityID') ? '&SecurityID=' + $('SecurityID').value : ''),
- onComplete: function(){
- Effect.Fade(
- row,
- {
- afterFinish: function(obj) {
- // remove row from DOM
- obj.element.parentNode.removeChild(obj.element);
- // recalculate summary if needed (assumes that TableListField.js is present)
- // TODO Proper inheritance
- if(this._summarise) this._summarise();
- // custom callback
- if(this.callback_deleteRecord) this.callback_deleteRecord(e);
- }.bind(this)
+ jQuery.ajax({
+ 'url': link.getAttribute("href"),
+ 'method': 'post',
+ 'data': {'forceajax': 1, 'SecurityID': $('SecurityID') ? $('SecurityID').value : null},
+ 'success': function(){
+ Effect.Fade(
+ row,
+ {
+ afterFinish: function(obj) {
+ // remove row from DOM
+ obj.element.parentNode.removeChild(obj.element);
+ // recalculate summary if needed (assumes that TableListField.js is present)
+ // TODO Proper inheritance
+ if(self._summarise) self._summarise();
+ // custom callback
+ if(self.callback_deleteRecord) self.callback_deleteRecord(e);
}
- );
- }.bind(this),
- onFailure: this.ajaxErrorHandler
- }
- );
+ }
+ );
+ },
+ 'error': this.ajaxErrorHandler
+ });
}
Event.stop(e);
@@ -55,17 +55,15 @@ CommentTableField.prototype = {
var row = Event.findElement(e,"tr");
img.setAttribute("src",'cms/images/network-save.gif'); // TODO doesn't work in Firefox1.5+
- new Ajax.Request(
- link.getAttribute("href"),
- {
- method: 'post',
- postBody: 'forceajax=1',
- onComplete: function(){
- Effect.Fade(row);
- }.bind(this),
- onFailure: function(response) {errorMessage('Server Error', response);}
- }
- );
+ jQuery.ajax({
+ 'url': link.getAttribute("href")
+ 'method': 'post',
+ 'data': 'forceajax=1',
+ 'success': function(){
+ Effect.Fade(row);
+ },
+ 'error': function(response) {errorMessage('Server Error', response);}
+ });
Event.stop(e);
},
@@ -341,13 +341,15 @@ function ajaxSubmitFieldSet(href, fieldSet, extraData) {
data += '&'+extraData;
}
// Send request
- new Ajax.Request(href, {
- method : 'post', postBody : data,
- onSuccess : function(response) {
+ jQuery.ajax({
+ 'url': href,
+ 'method' : 'post',
+ 'data' : data,
+ 'success' : function(response) {
//alert(response.responseText);
Ajax.Evaluator(response);
},
- onFailure : function(response) {
+ 'error' : function(response) {
alert(response.responseText);
//errorMessage('Error: ', response);
}
@@ -122,12 +122,14 @@ WidgetAreaEditorClass.prototype = {
this.name = holder;
- new Ajax.Request('Widget_Controller/EditableSegment/' + className, {
- onSuccess : $('usedWidgets-'+holder).parentNode.parentNode.insertWidgetEditor.bind(this)
+ jQuery.ajax({
+ 'url': 'Widget_Controller/EditableSegment/' + className,
+ 'success' : $('usedWidgets-'+holder).parentNode.parentNode.insertWidgetEditor.bind(this)
});
},
updateWidgets: function() {
+ var self = this;
// Gotta get the name of the current dohickey based off the ID
this.name = this.element.id.split('-').pop();
@@ -149,8 +151,11 @@ WidgetAreaEditorClass.prototype = {
var wIdArray = widget.id.split('-');
wIdArray.pop();
- new Ajax.Request('Widget_Controller/EditableSegment/' + wIdArray.join('-'), {
- onSuccess : $('usedWidgets-'+this.name).parentNode.parentNode.insertWidgetEditor.bind(this)
+ jQuery.ajax({
+ 'url': 'Widget_Controller/EditableSegment/' + wIdArray.join('-'),
+ 'success' : function() {
+ $('usedWidgets-'+self.name).parentNode.parentNode.insertWidgetEditor();
+ }
});
}
}

0 comments on commit 0e9bf07

Please sign in to comment.