This should be fairly simply if you save the items selected.(如果保存选择的项目,这应该非常简单。)
For example:(例如:)
<select data-placeholder="Choose a country..." style="width:350px;" multiple="true" class="chosen-select">
$(".chosen-select").chosen();
Now, before updating the chosen, make sure you save the items selected like this:(现在,在更新所选内容之前,请确保保存选择的项目,如下所示:)
var chosenSelectedItems = $(".chosen-select").val(); // this gets you the select value data
// Update the select items
$('.chosen-select').trigger('liszt:updated');
$(".chosen-select").val(chosenSelectedItems);
This should be able to reset the original values before the change.(这应该能够在更改之前重置原始值。) 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…