I'm developing a course block that has an autocomplete input with the users of the current course (fixed data, not ajax loaded). Until here, everything works fine, but I need to update the selected value of the autocomplete with jQuery when the user perform some actions on the screen. When I change the selected value of the select (like jQuery('#myautocomplete option[value="targetvalue"]').attr('selected', true)), the autocomplete does not update itself and the chip is not updated until I manually select another option and then, two chips are created.
So, my question is: how can I update the autocomplete input and make the chips appear using jQuery to update the selected value?
Obs: I've already read the docs, but it did not help.