Hi,

I successfully created depending sliders with prototype and slider.js.
See the result here: http://www.soa-world.de/dev/slider/slider.html
(here's the code: http://pastebin.com/ma1e82eb)
There is one problem with my code. What I do is I have a sliders class

"function sliders()"

inside I create the 5 sliders in a for loop and store them inside an
array which is a member of the class:

for()
{
   this.sliders[i].ctrl = new Control.Slider();
}

I then add callbacks for the onChange and onSlide events also inside
the loop with:

this.sliders[i].ctrl.options.onSlide = handleSliderChange;
this.sliders[i].ctrl.options.onChange = handleSliderChange;

In the callback I get two parameters: the new value and the slider
that triggered the event. To do my stuff I now need one more thing: a
reference to the array that contians ALL the sliders - naturally you
would think this.sliders[] but no of course not, the event callback
doesn't recognize the this keyword anymore because it doesn't know it
belongs to the sliders class. I worked around this by using the object
I create and access the array there so I write:

s = new sliders();

and inside the callback I access the array:

s.sliders[]

but I think that's ugly. I tried it using bindAsEventListener - that
worked as far as the this keyword goes. I could access the array then
via this.sliders however I lost the second parameter for my callback
so I didn't know which slider triggered the event.

How could I make this work?
Thanks in advance,
Sebastian S.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to rubyonrails-spinoffs@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to