Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

select2 remove selected value

$("#dynamicAttributes").val(null).trigger("change"); 
Comment

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');
Comment

PREVIOUS NEXT
Code Example
Javascript :: nuxt js file other site 
Javascript :: jquery append after number of chars in string 
Javascript :: rethrow error javascript 
Javascript :: template literals javascript 
Javascript :: days between two dates 
Javascript :: get bytes from string javascript 
Javascript :: change object in array in state 
Javascript :: find remainder in javascript 
Javascript :: jquery create array 
Javascript :: how to check if the number inputed is number 
Javascript :: Uncaught TypeError: Data.filter is not a function 
Javascript :: how get count of letters in javascript 
Javascript :: update a certain key in dictionary javascript 
Javascript :: flatten nested json objects 
Javascript :: kick members node js 
Javascript :: animated typing js 
Javascript :: select id get option value jquery 
Javascript :: js onclick 
Javascript :: js loop through form inputs 
Javascript :: get the location of an item in an array 
Javascript :: data fetch with axios 
Javascript :: background colour in react 
Javascript :: javascript encryption decryption 
Javascript :: google tuner 
Javascript :: jsp date 
Javascript :: react context api 
Javascript :: js reverse string 
Javascript :: react functional components shortcut in webstorm 
Javascript :: add color to attribute using jquery 
Javascript :: vue js get routes 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =