diff --git a/www/include/common/javascript/centreon/centreon-select2.js b/www/include/common/javascript/centreon/centreon-select2.js
index eacfbf5545e..35ec4540fc6 100644
--- a/www/include/common/javascript/centreon/centreon-select2.js
+++ b/www/include/common/javascript/centreon/centreon-select2.js
@@ -519,24 +519,23 @@
selectElements: function (elements) {
var self = this;
var item;
- var option;
var selectedElements;
if (this.remoteData) {
/* Append new elements */
+ let options = '';
for (var i = 0; i < elements.length; i++) {
item = elements[i];
/* Create DOM option that is pre-selected by default */
- option = '';
-
- /* Append it to select */
- self.$elem.append(option);
+ options += '>' + item.text + '';
}
+ /* Append it to select */
+ self.$elem.append(options);
} else {
/* Select existing elements */
selectedElements = elements.map(function (object) {
diff --git a/www/lib/HTML/QuickForm/select2.php b/www/lib/HTML/QuickForm/select2.php
index 581b9e161d2..703000f28c4 100644
--- a/www/lib/HTML/QuickForm/select2.php
+++ b/www/lib/HTML/QuickForm/select2.php
@@ -477,28 +477,28 @@ public function setDefaultAjaxDatas()
$ajaxDefaultDatas = '$request' . $this->getName() . ' = jQuery.ajax({
url: "' . $this->_defaultDatasetRoute . '",
});
-
+
$request' . $this->getName() . '.success(function (data) {
+ let options = "";
for (var d = 0; d < data.length; d++) {
var item = data[d];
-
+
// Create the DOM option that is pre-selected by default
- var option = "";
-
- // Append it to the select
- $currentSelect2Object' . $this->getName() . '.append(option);
+ options += ">" + item.text + "";
}
-
+ // Append it to the select
+ $currentSelect2Object' . $this->getName() . '.append(options);
+
// Update the selected options that are displayed
$currentSelect2Object' . $this->getName() . '.trigger("change",[{origin:\'select2defaultinit\'}]);
});
$request' . $this->getName() . '.error(function(data) {
-
+
});
';