Jui Slider

Hi,

I’m just converting some Yii 1.1 to Yii 2.0. When it came to the slider, I can’t get the value of the slider into my other div.




			echo Slider::widget([

				'id' => 'range-slide',

				'clientOptions' => [

					'min'=>20,

					'max'=>1000,

					'value'=>200,

					'step'=>10,

					'slide'=>'js:function(event, ui) { $("#radius").val(ui.value);}',

					'range'=>'min',

					'animate'=>true,

		      	],

			]);



My JQuery is a little rusty and I haven’t used 2.0 before. What am I doing wrong here, I did take a look at the docs.

I’m just trying to update a div with what the value of the slider actually is.

I have this as my code. But it doesn’t work. But when I run it in the console it does work. I slide the slider and it updates the radius field. :huh:




'slide'=>'js:$("#range-slide").on("slide", function( event, ui ) {$("#radius").val(ui.value)} );',



Can you check what’s generated via viewing page source?

Sure,




jQuery(document).ready(function(){

jQuery('#range-slide').slider({"min":20,"max":1000,"value":200,"step":10,"slide":"$(\"#range-slide\").on(\"slide\", function( event, ui ) {$(\"#radius\").val(ui.value)} );","range":"min","animate":true});

});



Aha. It seems you’re using old style “js:” that’s not supported by 2.0. You should wrap your code with JsExpression.

Also there’s SliderInput.

Ahh, thanks i’ll look into that. I did think it was due to the that, but couldn’t work out that i’d done it wrong. Thanks!