Country: Displays a bunch of countries, e.g. [“France”, “Germany”]
City: Displays a bunch of cities depending on what’s selected in Country. If you select “France” then the city list shows [“Paris”, “Marseille”], and when you select “Germany” it displays [“Berlin”, “Hamburg”].
So far, so good. Setting up a callback that updates the City list based on the selected Country is trivial.
The problem arises when I want to additionally control both Country and City via a third input upstream, e.g. the URL (think foo.com?country=Germany&city=Hamburg). Then we have the following dependency graphs:
URL -> [Country, City]
Country -> City
In an ideal world we could implement this as two independent callbacks, but that’s not possible according to the FAQ:
So, given that City is an output of both callback 1 and 2 we need to merge both callbacks into one. That is, however, impossible because Country would have to be both an input and an output of the callback, which is not allowed.
Maybe you could organise your callbacks differently to something like
URL -> Country
[URL, Country] -> City
Possibly also relevant would be dash.callback_context which would let you figure out which input triggered the second callback. You can read about that here under the question “How do I determine which Input has changed?”
Thanks, but I can’t re-organize that way, because I really need the URL to be able to control both Country and City.
The callback context doesn’t help me here because dash won’t allow me to set up a callback with Country being both the input and the output of a callback in the first place.