G
George
Being nebie in Javascript i am trying to code my own helper object
that does pagination.
So here is a snippet of my code.
MyData.prototype = {
....blablabla...
PageUp: function() {
this.iFrom += this.pageSize;
this.CheckPageIndex();
},
CheckPageIndex: function() {
if( this.iFrom >= this.data.length )
this.iFrom = Math.floor((this.data.length - 1)/
this.pageSize) * this.pageSize;
if( this.iFrom < 0 )
this.iFrom = 0;
}
}
Why do I need to call CheckPageIndex using this.CheckPageIndex when
called from PageUp? It's in the same object...
Without 'this' I get an error 'CheckPageIndex is undefined'. Coming
from object oriented languages like C++ I have a trouble understanding
it.
Or am I doing it wrong and there is a way not to specify 'this' to
many times?
that does pagination.
So here is a snippet of my code.
MyData.prototype = {
....blablabla...
PageUp: function() {
this.iFrom += this.pageSize;
this.CheckPageIndex();
},
CheckPageIndex: function() {
if( this.iFrom >= this.data.length )
this.iFrom = Math.floor((this.data.length - 1)/
this.pageSize) * this.pageSize;
if( this.iFrom < 0 )
this.iFrom = 0;
}
}
Why do I need to call CheckPageIndex using this.CheckPageIndex when
called from PageUp? It's in the same object...
Without 'this' I get an error 'CheckPageIndex is undefined'. Coming
from object oriented languages like C++ I have a trouble understanding
it.
Or am I doing it wrong and there is a way not to specify 'this' to
many times?