Skip to content

Commit 80b2a0b

Browse files
author
Dmitry Kuzin (DevExpress)
committed
1 parent 7a15162 commit 80b2a0b

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

src/jquery-bar-rating.js

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,39 @@ function init(Survey, $) {
4949
},
5050
afterRender: function(question, el) {
5151
var $el = $(el).is("select") ? $(el) : $(el).find("select");
52-
$el.barrating("show", {
53-
theme: question.ratingTheme,
54-
initialRating: question.value,
55-
showValues: question.showValues,
56-
showSelectedRating: false,
57-
onSelect: function(value, text) {
58-
question.value = value;
59-
}
60-
});
52+
var creator = function() {
53+
$el.barrating("show", {
54+
theme: question.ratingTheme,
55+
initialRating: question.value,
56+
showValues: question.showValues,
57+
showSelectedRating: false,
58+
onSelect: function(value, text) {
59+
question.value = value;
60+
}
61+
});
62+
}
63+
creator();
6164
question.valueChangedCallback = function() {
6265
$(el)
6366
.find("select")
6467
.barrating("set", question.value);
6568
};
69+
question.__barratingOnPropertyChangedCallback = function(sender, options) {
70+
if (options.name == "ratingTheme") {
71+
$el.barrating("destroy");
72+
creator();
73+
}
74+
};
75+
question.onPropertyChanged.add(
76+
question.__barratingOnPropertyChangedCallback
77+
);
6678
},
6779
willUnmount: function(question, el) {
6880
var $el = $(el).find("select");
6981
$el.barrating("destroy");
82+
question.valueChangedCallback = undefined;
83+
question.onPropertyChanged.remove(question.__barratingOnPropertyChangedCallback);
84+
question.__barratingOnPropertyChangedCallback = undefined;
7085
}
7186
};
7287

0 commit comments

Comments
 (0)