You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there any functionality for destroying, or refreshing the current multiselect?
What I means is that for dynamic multiselect values from AJAX, when the list in the right box is updated dynamically, how to update the left box, like removing the values that are already selected in the left box. I'm sorry if my word is confusing.
What I did right now is, I reused your codes in the initialized function. When I the left box value is updated, I call this function:
function refreshMultiselect() {
var right = $('#optgroup_to');
var left = $('#optgroup');
right.find('option').each(function(index, rightOption) {
if ($(rightOption).parent().prop('tagName') == 'OPTGROUP') {
var optgroupSelector = 'optgroup[label="' + $(rightOption).parent().attr('label') + '"]';
left.find(optgroupSelector + ' option[value="' + rightOption.value + '"]').each(function(index, leftOption) {
leftOption.remove();
});
left.find(optgroupSelector).removeIfEmpty();
} else {
var $option = left.find('option[value="' + rightOption.value + '"]');
$option.remove();
}
});
}
The text was updated successfully, but these errors were encountered:
I had a multiselect and wanted to change the content when i selected an other group in a select.
At first the multiselect kept old data.
I seem have solved the problem by turning off all the elements i used, and after that reinitilize the multiselect ( in js.haml)
Is there any functionality for destroying, or refreshing the current multiselect?
What I means is that for dynamic multiselect values from AJAX, when the list in the right box is updated dynamically, how to update the left box, like removing the values that are already selected in the left box. I'm sorry if my word is confusing.
What I did right now is, I reused your codes in the initialized function. When I the left box value is updated, I call this function:
The text was updated successfully, but these errors were encountered: