jonny
(Jonny)
1
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.
jonny
(Jonny)
2
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:](http://www.yiiframework.com/forum/public/style_emoticons/default/huh.gif)
'slide'=>'js:$("#range-slide").on("slide", function( event, ui ) {$("#radius").val(ui.value)} );',
samdark
(Alexander Makarov)
3
Can you check what’s generated via viewing page source?
jonny
(Jonny)
4
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});
});
samdark
(Alexander Makarov)
5
Aha. It seems you’re using old style “js:” that’s not supported by 2.0. You should wrap your code with JsExpression.
samdark
(Alexander Makarov)
6
Also there’s SliderInput.
jonny
(Jonny)
7
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!