Permalink
Browse files

MINOR Using jQuery ajax methods in AssetTableField and MemberTableFie…

…ld (instead of the prototype library functions which are not fully compatible with jQuery.ondemand at the moment). Fixed TableListField.js errors.
  • Loading branch information...
chillu committed Apr 19, 2011
1 parent 0271652 commit 895b98116db8c6382ab30cbbda6c271e04c1561e
Showing with 22 additions and 41 deletions.
  1. +17 −26 admin/javascript/AssetTableField.js
  2. +2 −11 admin/javascript/MemberTableField.js
  3. +3 −4 javascript/TableListField.js
@@ -124,9 +124,7 @@ AssetTableField.prototype = {
},
deleteRecord: function(e) {
- var img = Event.element(e);
- var link = Event.findElement(e,"a");
- var row = Event.findElement(e,"tr");
+ var self = this, img = Event.element(e), link = Event.findElement(e,"a"), row = Event.findElement(e,"tr");
var linkCount = row.getElementsByClassName('linkCount')[0];
if(linkCount) linkCount = linkCount.innerHTML;
@@ -139,30 +137,23 @@ AssetTableField.prototype = {
if(confirmed)
{
img.setAttribute("src",'sapphire/admin/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)
- }
- );
- }.bind(this),
- onFailure: this.ajaxErrorHandler
+ jQuery.ajax({
+ url: link.getAttribute("href"),
+ method: 'post',
+ data: {forceajax: 1, SecurityID: jQuery('input[name=SecurityID]').val()},
+ success: function() {
+ jQuery(row).fadeOut('fast', function() {
+ // remove row from DOM
+ this.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);
+ }
}
- );
+ });
+
}
Event.stop(e);
@@ -307,14 +307,7 @@ MemberFilterButton.prototype = {
}
updateURL += ($('SecurityID') ? '&SecurityID=' + $('SecurityID').value : '');
- new Ajax.Updater( fieldID, updateURL, {
- onComplete: function() {
- Behaviour.apply($(fieldID), true);
- },
- onFailure: function( response ) {
- errorMessage('Could not filter results: ' + response.responseText );
- }
- });
+ jQuery($(fieldID)).get(updateURL, null, function() {Behaviour.apply($(fieldID), true);});
} catch(er) {
errorMessage('Error searching');
}
@@ -346,12 +339,10 @@ function ajaxSubmitFieldSet(href, fieldSet, extraData) {
'method' : 'post',
'data' : data,
'success' : function(response) {
- //alert(response.responseText);
- Ajax.Evaluator(response);
+ eval(response);
},
'error' : function(response) {
alert(response.responseText);
- //errorMessage('Error: ', response);
}
});
}
@@ -97,7 +97,7 @@ TableListField.prototype = {
jQuery.ajax({
'url': link.getAttribute("href"),
'method': 'post',
- 'data': {forceajax: 1, SecurityID: $('SecurityID') ? $('SecurityID').value : null},
+ 'data': {forceajax: 1, SecurityID: jQuery('input[name=SecurityID]').val()},
'success': function(){
Effect.Fade(
row,
@@ -183,13 +183,12 @@ TableListField.prototype = {
if(el.getAttribute('href')) {
jQuery.ajax({
'url': el.getAttribute('href'),
- 'data': {'update': 1, 'params': (params)},
+ 'data': {'update': 1},
'success': function(response) {
- Element.replace(self.id, response.responseText);
+ jQuery('#' + self.id).replaceWith(response)
// reapply behaviour and reattach methods to TF container node
// e.g. <div class="TableListField">
Behaviour.apply($(self.id), true);
- if(oncomplete) oncomplete.apply(response);
}
});
}

0 comments on commit 895b981

Please sign in to comment.