Skip to content

Commit 94e821d

Browse files
committed
Fix the bug with setting default value for nouislider
1 parent df5469c commit 94e821d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/nouislider.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ function init(Survey) {
3030
]);
3131
},
3232
afterRender: function(question, el) {
33-
question.value = (question.rangeMin + question.rangeMax) / 2;
33+
if (question.isEmpty()) {
34+
question.value = (question.rangeMin + question.rangeMax) / 2;
35+
}
3436

3537
el.style.marginBottom = "50px";
3638
var slider = noUiSlider.create(el, {
@@ -57,6 +59,7 @@ function init(Survey) {
5759
if (question.isReadOnly) {
5860
el.setAttribute("disabled", true);
5961
}
62+
updateValueHandler();
6063
question.noUiSlider = slider;
6164
question.valueChangedCallback = updateValueHandler;
6265
question.readOnlyChangedCallback = function() {
@@ -65,7 +68,7 @@ function init(Survey) {
6568
} else {
6669
el.removeAttribute("disabled");
6770
}
68-
}
71+
};
6972
},
7073
willUnmount: function(question, el) {
7174
question.noUiSlider.destroy();

0 commit comments

Comments
 (0)