Using Pipeline from a class

Using Pipeline from a class

iisfaqiisfaq Posts: 9Questions: 2Answers: 0

I want to put all the logic of the pipline from http://datatables.net/dev/accessibility/DataTables/examples/server_side/pipeline.html
into a class.

But I find that the this is dthe datatables object and not the object I created...

My knowledge of JS at this level is not very good.

var Pipeline = function () {
this.ABC = "123";
}

Pipeline.prototype.fnDataTablesPipeline = function(sSource, aoData, fnCallback) {
alert(this.ABC);
}

and

var p = new Pipeline();
$('#tableactive').dataTable(
{
"order": [[1, "asc"]],
"deferRender": true,
"bServerSide": true,
"iDisplayStart": 0,
"iDisplayLength": 25,
"sAjaxSource": "/api/json/syncreply/Request_GetOpen"
"fnServerData": p.fnDataTablesPipeline,

Using the code above the fnDataTablesPipeline() is called from dataTables.

But the this.ABC is undefined and this is actually by the looks of it the DataTables object itself.

How do I access properties of my object? in this case the ABC property?

Answers

  • allanallan Posts: 63,680Questions: 1Answers: 10,498 Site admin

    Try adding console.log( this ); in your pipeline function. It could be that the scope of execution is different. If you could link to a test case that would be useful.

    Allan

  • iisfaqiisfaq Posts: 9Questions: 2Answers: 0

    Hi

    I found another example which did what I needed.

    http://datatables.net/examples/server_side/pipeline.html

    Chris

  • allanallan Posts: 63,680Questions: 1Answers: 10,498 Site admin

    Interesting - the page you found before (which I hadn't realised) is of a very old version. I should remove that - thanks for letting me know about it.

    Allan

This discussion has been closed.