Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Update select2 after removing an element

var newArray = [];
let newData = $.grep($('#select2').select2('data'), function (value) {
return value['id'] != id_to_remove;
});

newData.forEach(function(data) {
newArray.push(+data.id);
});

$('#select2').val(newArray).trigger('change');
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Update #removing #element
ADD COMMENT
Topic
Name
3+9 =