by j74kennedy on Tue Sep 09, 2008 1:24 pm
The following will do what you want:
1. Add new "initVal" to the options, defined in slider.js
options: {
onChange: Class.empty,
onComplete: Class.empty,
onTick: function(pos){
this.knob.setStyle(this.p, pos);
},
mode: 'horizontal',
steps: 100,
initVal: 0,
offset: 0
},
2. Update the line:
this.knob.setStyle('position', 'relative').setStyle(this.p, - this.options.offset);
to
this.knob.setStyle('position', 'relative').setStyle(this.p, this.options.initVal);
3. When creating slider object in your javascript code, add "initVal:[default value]":
e.g.
var slider1 = new Slider('slideContainer1', 'slideHandle1',{
initVal:50, onComplete: function(val){$('pos1').setHTML(val);}});
4. Set the pos field to the value you used for the default value so it will match the slider position
e.g.
$('pos1').setHTML(50);
So the complete javascript definition would be:
e.g.
window.addEvent('domready', function(){
var slider1 = new Slider('slideContainer1', 'slideHandle1',{
initVal:50, onComplete: function(val){$('pos1').setHTML(val);}});
$('pos1').setHTML(50);
});
Thats it