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) {
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);

View File

@ -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);
}
});
}

View File

@ -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);
}
});
}