mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
0271652aa3
commit
895b98116d
@ -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',
|
||||||
postBody: 'forceajax=1' + ($('SecurityID') ? '&SecurityID=' + $('SecurityID').value : ''),
|
data: {forceajax: 1, SecurityID: jQuery('input[name=SecurityID]').val()},
|
||||||
onComplete: function(){
|
success: function() {
|
||||||
Effect.Fade(
|
jQuery(row).fadeOut('fast', function() {
|
||||||
row,
|
|
||||||
{
|
|
||||||
afterFinish: function(obj) {
|
|
||||||
// remove row from DOM
|
// remove row from DOM
|
||||||
obj.element.parentNode.removeChild(obj.element);
|
this.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(this._summarise) this._summarise();
|
if(self._summarise) self._summarise();
|
||||||
// custom callback
|
// custom callback
|
||||||
if(this.callback_deleteRecord) this.callback_deleteRecord(e);
|
if(self.callback_deleteRecord) self.callback_deleteRecord(e);
|
||||||
}.bind(this)
|
|
||||||
}
|
}
|
||||||
);
|
|
||||||
}.bind(this),
|
|
||||||
onFailure: this.ajaxErrorHandler
|
|
||||||
}
|
}
|
||||||
);
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Event.stop(e);
|
Event.stop(e);
|
||||||
|
@ -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);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
@ -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);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user