So I've been trying to update the options in a selection menu by changing the list that I use to determine the possible options for the selected city. (Part of the code will be shown at the end of this tekst)
I've been trying to update this plot using JS Callbacks but the only thing that works is when I update a source with source.change.emit(). So what I'm asking is: Is there a way to update a list instead of a source using JS Callbacks?
The code below is just a small bit of my actual code but should be enough to bring the message across. This is because my university looks down on fraud and I don't want to give them any reason to think that I committed something like that.
user_list = ["User1", "User2", "User3"]
callback = CustomJS(args=dict(users=user_list), code= """
users = [];
users.push("User2");
users.push("User3");
users.change.emit(); //This line does not work and I am wondering if it can be done differently
"""
I hope that this is enough explanation of my current dilemma and I hope you guys can help a fellow out!
Thanks in advance!
UPDATED VERSION, in response to the answer given to solve this problem The following code should be the correct code:
#Import of libraries here
select = MultiSelect(title="Users:", value=["User1"],
options=["User1", "User2", "User3"] )
callback = CustomJS(args=dict(users=select), code= """
users.options=["User2", "User3"];
users.value=["User2"];
"""
If everything is right, this should work.