The plugin authoring page won't help you much building a "class" in javascript. If you want to use the this keyword less you can use private variables: http://javascript.crockford.com/private.html and there are some more great sources here: http://www.crockford.com/javascript/
But transforming a complex generic js class to a jQuery plugin is another story as a plugin should generally return a jQuery object. Some patterns regarding this issue came up here: http://groups.google.com/group/jquery-en/browse_thread/thread/9dc9be1cc298cbdd After reading the article on private variables it should be clear, but briefly the the problem is that if you don't use the this keyword then CheckPageIndex will be a reference to a variable in the closure (function) you use it, or if it doesn't exist there then it will be a global variable. And this way you don't have any closure that could remember the variable. So you need to define things in a closure (function). Anyway, it's much better explained in the article :) On Nov 10, 6:29 pm, George <[EMAIL PROTECTED]> wrote: > I had looked there probably 10 times :) > Are you implying that I need to convert my code to being Plug-In? > Other than that I do not see how this > pagehttp://docs.jquery.com/Plugins/Authoring > answers my question... > Sorry, but please spell it out for me. > > The Plug-In would be the next step for me.. But as of now I am trying > to nail down the use of 'this' in JavaScript as it's a bit different > from what I am used to. > > George. > > On Nov 10, 11:43 am, "Olivier Percebois-Garve" <[EMAIL PROTECTED]> > wrote: > > > you may want to have a look herehttp://docs.jquery.com/Plugins/Authoring > > > On Mon, Nov 10, 2008 at 5:20 PM, George <[EMAIL PROTECTED]> wrote: > > > > Being newbie 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? > > > > Thanks > > > George- Hide quoted text - > > > - Show quoted text -