After refactoring my code to use proper objects, I am facing an issue with getting Prototype's AJAX.Request to work correctly. The code snippet below is functioning within the context of YUI's DataTable:
SearchTable.prototype.setTableColumns = function (transport) {
this.dataTableColumns = transport.responseText.evalJSON();
this.dataTableCallback();
};
SearchTable.prototype.setTableConfiguration = function (transport) {
this.dataTableConfiguration = transport.responseText.evalJSON();
this.dataTableCallback();
};
SearchTable.prototype.show = function () {
....
new Ajax.Request(this.dataProxy, {
method: 'get',
parameters: {
format: 'json',
param: 'columns'
},
onSuccess: this.setTableColumns
});
new Ajax.Request(this.dataProxy, {
method: 'get',
parameters: {
format: 'json',
param: 'configuration'
},
onSuccess: this.setTableConfiguration
});
}
};
SearchTable.prototype.dataTableCallback = function () {
....
}
The issue I am encountering is that dataTableCallback
is not being called at all. It seems to be throwing an exception stating that this
is undefined, which is understandable as callbacks are not executed in object context and therefore this
remains unassigned. I have attempted to curry callbacks without success.
So, my question is: How can I resolve this problem and make it work as intended?