MINOR Using jQuery ajax methods in AssetTableField and MemberTableField (instead of the prototype library functions which are not fully compatible with jQuery.ondemand at the moment). Fixed TableListField.js errors.

This commit is contained in:
Ingo Schommer 2011-04-19 21:18:35 +12:00
parent 0271652aa3
commit 895b98116d
3 changed files with 22 additions and 41 deletions

View File

@ -124,9 +124,7 @@ AssetTableField.prototype = {
}, },
deleteRecord: function(e) { deleteRecord: function(e) {
var img = Event.element(e); var self = this, img = Event.element(e), link = Event.findElement(e,"a"), row = Event.findElement(e,"tr");
var link = Event.findElement(e,"a");
var row = Event.findElement(e,"tr");
var linkCount = row.getElementsByClassName('linkCount')[0]; var linkCount = row.getElementsByClassName('linkCount')[0];
if(linkCount) linkCount = linkCount.innerHTML; if(linkCount) linkCount = linkCount.innerHTML;
@ -139,30 +137,23 @@ AssetTableField.prototype = {
if(confirmed) if(confirmed)
{ {
img.setAttribute("src",'sapphire/admin/images/network-save.gif'); // TODO doesn't work img.setAttribute("src",'sapphire/admin/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: jQuery('input[name=SecurityID]').val()},
postBody: 'forceajax=1' + ($('SecurityID') ? '&SecurityID=' + $('SecurityID').value : ''), success: function() {
onComplete: function(){ jQuery(row).fadeOut('fast', function() {
Effect.Fade( // remove row from DOM
row, this.element.parentNode.removeChild(obj.element);
{ // recalculate summary if needed (assumes that TableListField.js is present)
afterFinish: function(obj) { // TODO Proper inheritance
// remove row from DOM if(self._summarise) self._summarise();
obj.element.parentNode.removeChild(obj.element); // custom callback
// recalculate summary if needed (assumes that TableListField.js is present) if(self.callback_deleteRecord) self.callback_deleteRecord(e);
// 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
} }
); });
} }
Event.stop(e); Event.stop(e);

View File

@ -307,14 +307,7 @@ MemberFilterButton.prototype = {
} }
updateURL += ($('SecurityID') ? '&SecurityID=' + $('SecurityID').value : ''); updateURL += ($('SecurityID') ? '&SecurityID=' + $('SecurityID').value : '');
new Ajax.Updater( fieldID, updateURL, { jQuery($(fieldID)).get(updateURL, null, function() {Behaviour.apply($(fieldID), true);});
onComplete: function() {
Behaviour.apply($(fieldID), true);
},
onFailure: function( response ) {
errorMessage('Could not filter results: ' + response.responseText );
}
});
} catch(er) { } catch(er) {
errorMessage('Error searching'); errorMessage('Error searching');
} }
@ -346,12 +339,10 @@ function ajaxSubmitFieldSet(href, fieldSet, extraData) {
'method' : 'post', 'method' : 'post',
'data' : data, 'data' : data,
'success' : function(response) { 'success' : function(response) {
//alert(response.responseText); eval(response);
Ajax.Evaluator(response);
}, },
'error' : function(response) { 'error' : function(response) {
alert(response.responseText); alert(response.responseText);
//errorMessage('Error: ', response);
} }
}); });
} }

View File

@ -97,7 +97,7 @@ TableListField.prototype = {
jQuery.ajax({ jQuery.ajax({
'url': link.getAttribute("href"), 'url': link.getAttribute("href"),
'method': 'post', 'method': 'post',
'data': {forceajax: 1, SecurityID: $('SecurityID') ? $('SecurityID').value : null}, 'data': {forceajax: 1, SecurityID: jQuery('input[name=SecurityID]').val()},
'success': function(){ 'success': function(){
Effect.Fade( Effect.Fade(
row, row,
@ -183,13 +183,12 @@ TableListField.prototype = {
if(el.getAttribute('href')) { if(el.getAttribute('href')) {
jQuery.ajax({ jQuery.ajax({
'url': el.getAttribute('href'), 'url': el.getAttribute('href'),
'data': {'update': 1, 'params': (params)}, 'data': {'update': 1},
'success': function(response) { 'success': function(response) {
Element.replace(self.id, response.responseText); jQuery('#' + self.id).replaceWith(response)
// reapply behaviour and reattach methods to TF container node // reapply behaviour and reattach methods to TF container node
// e.g. <div class="TableListField"> // e.g. <div class="TableListField">
Behaviour.apply($(self.id), true); Behaviour.apply($(self.id), true);
if(oncomplete) oncomplete.apply(response);
} }
}); });
} }