Fix selectize bug when multiple selectize fields exist on the same page

This commit is contained in:
jf-cbd
2024-06-05 10:26:26 +02:00
committed by Benjamin Dalsass
parent 1e3c425e81
commit 141c22ff67

View File

@@ -4,7 +4,6 @@
{# SET WIDGET #}
{% set oDataProvider = oUIBlock.GetDataProvider() %}
let optionsBeforeFilter;
let oWidget{{ oUIBlock.GetId() }} = $('#{{ oUIBlock.GetId() }}').selectize({
{# Global options #}
@@ -109,7 +108,7 @@ let oWidget{{ oUIBlock.GetId() }} = $('#{{ oUIBlock.GetId() }}').selectize({
// Filter old options data to keep selected values
// (options with force flag will be kept event if they doesn't be part of the current value)
let options = Object.values(me.options);
optionsBeforeFilter = options;
me.optionsBeforeFilter = options;
options = options.filter(item => (typeof(item.force) !== "undefined" && item.force === true) || aSelectedItems.includes(item['{{ oDataProvider.GetDataValueField() }}']));
// Merge kept and new values
options = $.merge(options, res.data.search_data);
@@ -203,7 +202,7 @@ let oWidget{{ oUIBlock.GetId() }} = $('#{{ oUIBlock.GetId() }}').selectize({
onBlur: function(){
this.clearOptionGroups()
this.addOption(optionsBeforeFilter)
this.addOption(this.optionsBeforeFilter)
},
{# plugin combodo_add_button #}