@@ -131,7 +131,7 @@ public function init()
131131 }
132132
133133 if (!isset ($ this ->sliderOptions ['id ' ])) {
134- $ this ->sliderOptions ['id ' ] = $ this ->getId ();
134+ $ this ->sliderOptions ['id ' ] = "{ $ this ->getId ()} -slider " ;
135135 }
136136
137137 $ this ->addUpdateEvent ();
@@ -145,14 +145,15 @@ public function init()
145145 */
146146 protected function addUpdateEvent ()
147147 {
148+ $ containerId = $ this ->options ['id ' ];
148149 $ sliderId = $ this ->sliderOptions ['id ' ];
149150 $ this ->inputOptions ['data-slider-target ' ] = $ sliderId ;
150151
151152 if (!isset ($ this ->clientEvents ['update ' ])) {
152153 $ this ->clientEvents ['update ' ] = new JsExpression (<<<JS
153154function (values, handle) {
154- var value = values[handle];
155- $(' [data-slider-target=" {$ sliderId }"]').val( value) ;
155+ let value = values[handle];
156+ document.querySelector('# $ containerId [data-slider-target=" {$ sliderId }"]').value = value ;
156157}
157158JS
158159 );
@@ -189,14 +190,6 @@ protected function renderHtml5RangeInput()
189190 {
190191 $ html [] = Html::beginTag ('div ' , ['class ' => 'range-field ' ]);
191192
192- // workaround for: https://github.com/Dogfalo/materialize/issues/5761
193- if (!isset ($ this ->inputOptions ['min ' ])) {
194- $ this ->inputOptions ['min ' ] = 0 ;
195- }
196- if (!isset ($ this ->inputOptions ['max ' ])) {
197- $ this ->inputOptions ['max ' ] = 100 ;
198- }
199-
200193 if ($ this ->hasModel ()) {
201194 $ html [] = Html::activeInput ('range ' , $ this ->model , $ this ->attribute , $ this ->inputOptions );
202195 } else {
@@ -253,7 +246,7 @@ protected function registerClientScripts()
253246 if ($ this ->clientOptions !== false ) {
254247 $ options = empty ($ this ->clientOptions ) ? '{} ' : Json::htmlEncode ($ this ->clientOptions );
255248 $ view ->registerJs (<<<JS
256- var $ varName = document.getElementById(' $ id');
249+ let $ varName = document.getElementById(' $ id');
257250noUiSlider.create( $ varName, {$ options });
258251JS
259252 );
0 commit comments