Set Default Values For Range Slider Using Cjuisliderinput

Pretty much exactly as the topic, I can’t set the default values for the range slider. Here’s my code

$form->widget('zii.widgets.jui.CJuiSliderInput', array(













				'slide'=>'js:function(event, ui) {

			$("#amount").text("$" + ui.values[0] + " - $" + ui.values[1]);}',


Your code seems ok, with the exeption of the "value" key, which seems unnecessary when I read the documentation. Please try without it and check if it works.

Yeah that was just one of my attempts to get any default value but both sliders always at 0. I’ve tried using javascript to set the form values and move the sliders but none of that works.

Very strange. If you aready tried setting it using the values option, I can’t think of anything else.

Do you get javascript errors on your browser?

I don’t get any javascript errors during the initialization but when I tried to use jQuery to set the default values on load, I would get an error that said something like “[Object object] has no attribute ‘slider’”;

Please try setting a class with htmlOptions just to be sure your selector is correct.

Ok I added this to initialization



and this to javascript section



and this is the error

Uncaught TypeError: Object [object Object] has no method 'slider' 

I got curious and made some tests here. It seems that the slider will ignore any values passed as initial values unless the values of the model attributes. In your case, price_from and price_to.

You can assign default values on your model and it will work.