Phoenix Dynamically Fetch Data on Form Select change

What is needed to load new data when select change occurs into another Form input / select without reloading entire page? Phoenix / Elixir last versions.

It seems to be the frontend responsability to do this… Maybe some javascript, and a backend api to provide data on request?

It seems like a problem ajax solved years ago. But depending on the context, You might prefer other solution. Like loading all data (if the set is limited) client side and caching them with IndexDb, or local_storage. This will avoid round trip to the server.

There is also drab, to make the change server side.

Yeah, this is entirely a frontend issue. Both Drab and Unpoly both make this pretty trivial to do though if you want the server to control what is populated.

1 Like