Skip to content

Commit 98312bd

Browse files
author
Dmitry Kuzin (DevExpress)
committed
Fix for #221
1 parent 55ad077 commit 98312bd

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/select2.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ function init(Survey, $) {
6363
if (isSettingValue) return;
6464
question.comment = $otherElement.val();
6565
});
66+
6667
var updateComment = function () {
6768
$otherElement.val(question.comment);
6869
if (question.isOtherSelected) {
@@ -105,12 +106,18 @@ function init(Survey, $) {
105106
$el.select2(settings);
106107
question.keepIncorrectValues = true;
107108
} else {
108-
settings.data = question.visibleChoices.map(function (choice) {
109-
return {
110-
id: choice.value,
111-
text: choice.text,
112-
};
113-
});
109+
var data = [];
110+
if (!!settings.placeholder || question.showOptionsCaption) {
111+
data.push({ id: "", text: "" });
112+
}
113+
settings.data = data.concat(
114+
question.visibleChoices.map(function (choice) {
115+
return {
116+
id: choice.value,
117+
text: choice.text,
118+
};
119+
})
120+
);
114121
$el.select2(settings);
115122
}
116123
// fixed width accrording to https://stackoverflow.com/questions/45276778/select2-not-responsive-width-larger-than-container

0 commit comments

Comments
 (0)