Skip to content

Commit 615d34e

Browse files
fixed #52
1 parent c51e013 commit 615d34e

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/select2.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ function init(Survey, $) {
3131
});
3232
Survey.JsonObject.metaData.addProperty("dropdown", {
3333
name: "select2Config",
34-
default: {}
34+
default: null
3535
});
3636
}
3737
if (activatedBy == "customtype") {
3838
Survey.JsonObject.metaData.addClass("select2", [], null, "dropdown");
3939
Survey.JsonObject.metaData.addProperty("select2", {
4040
name: "select2Config",
41-
default: {}
41+
default: null
4242
});
4343
}
4444
},
@@ -68,8 +68,18 @@ function init(Survey, $) {
6868
var updateChoices = function () {
6969
$el.select2().empty();
7070

71-
if (settings.ajax) {
72-
$el.select2(settings);
71+
if (settings) {
72+
if (settings.ajax) {
73+
$el.select2(settings);
74+
} else {
75+
settings.data = question.visibleChoices.map(function (choice) {
76+
return {
77+
id: choice.value,
78+
text: choice.text
79+
};
80+
});
81+
$el.select2(settings);
82+
}
7383
} else {
7484
$el.select2({
7585
theme: "classic",
@@ -81,6 +91,7 @@ function init(Survey, $) {
8191
})
8292
});
8393
}
94+
8495
updateValueHandler();
8596
updateCommentHandler();
8697
};

0 commit comments

Comments
 (0)