Thanks!!, works great.
On Jan 14, 10:22 am, nutron <[email protected]> wrote: > You need to bind the "this": > onChange: function(){ ... }.bind(this) > > On Tue, Jan 13, 2009 at 1:07 PM, Matt Thomson (via Nabble) < > [email protected]<ml-user%[email protected]> > > > > > wrote: > > > Hi, I have about 5 scrollbars on my page, so I would rather have one > > class, than the five repeated bits of code I use currently. I have > > tried the below code, but the this.container is not available inside > > the onChange function. I am new to OOP in mootools, is there a way to > > fix this, or am I doing OOP the wrong way? > > > var scrollBarClass = new Class > > ({ > > initialize: function(container,scrollBarBack,handle) > > { > > > this.container = container; > > this.scrollBarBack = scrollBarBack; > > this.handle = handle; > > > this.SizeArray = $(this.container).getSize(); > > this.ScrollLength = this.SizeArray.scrollSize.y; > > this.BoxLength = this.SizeArray.size.y; > > > if(this.ScrollLength > this.BoxLength) > > { > > > $(this.scrollBarBack).setStyle('display', 'block'); > > $(this.handle).setStyle('display', 'block'); > > > this.ScrollBarSlider = new Slider(this.scrollBarBack, this.handle, > > { > > steps: 100, > > offset: 0, > > mode: 'vertical', > > > onChange: function(step) > > { > > //this is the problem part, the this.container is not available > > inside this function > > $(this.container).scrollTo(step * ( (this.ScrollLength - > > this.BoxLength) /100),0 ); > > }, > > onTick: function(pos) > > { > > this.knob.setStyle(\'top\', pos); > > } > > > }); > > } > > else > > { > > $(this.scrollBarBack).setStyle(\'display\', \'none\'); > > $(this.handle).setStyle(\'display\', \'none\'); > > }; > > } > > > }); > > > ------------------------------ > > View message @ > >http://n2.nabble.com/class-function-scope-problem-tp2153327p2153327.html > > To start a new topic under MooTools Users, email > > [email protected]<ml-node%[email protected]> > > To unsubscribe from MooTools Users, click here< (link removed) >. > > ----- > The MooTools Tutorial: http://www.mootorial.comwww.mootorial.com > Clientcide: http://www.clientcide.comwww.clientcide.com > -- > View this message in > context:http://n2.nabble.com/class-function-scope-problem-tp2153327p2153418.html > Sent from the MooTools Users mailing list archive at Nabble.com.
