z7ealth

z7ealth

Hi everyone,

I’m currently working on two projects with Phoenix and LiveView, and I’m looking for tips or suggestions on improving the frontend side. I’ve managed to implement basic functionality using core_components and LiveView.JS, but I get stuck when I need something more advanced. For example, I’m unsure how to dynamically update select options based on previous selections (e.g., select country → select state → select city), handle actions involving multiple checkboxes, or implement table sorting.

I’m still new to this, and I know it might just be a skill gap, which is why I’m reaching out. I’d love to hear how Saint Jose disciples approach and solve these kinds of challenges.

For context, I have a background in Ember.js with EmberPaper and React with Ant Design.

Showing Posts 1 to 8

joddm

joddm

Would also appreciate this :slightly_smiling_face:

I’m more comfortable with the back-end, and a total noob on front-end stuff

D4no0

D4no0

If you work currently on a toy project my advice is to not use JS at all, do everything server-side.

The trend I see currently being pushed in liveview ecosystem is interaction with JS from liveview, in order to avoid server latency, which is not exactly what liveview was built for. The idea of liveview is to simplify web development by keeping the frontend interaction on the elixir side, instead of having both JS and backend code like in your classical 2 stack web app. There is obviously a price to pay for this abstraction and that is your UI becomes janky if your connection is unstable.

The JS interlop is an important hack to overcome liveview limitations (for example interaction with JS libraries like maplibre.js), however IMO it should be used only when all other options are exhausted, as the more JS you use, the exponentially less benefit you get from using liveview.

Pal

Pal

You couldn’t do better than starting with:

Aiken00

Aiken00

how about pragmatic studio?

ipnon

ipnon

The best way to learn is to hack on the coolest project you can think of. With frameworks like React you can footgun and spend months or even years studying how to do everything the right way without ever writing a real line of code, let alone actually taking a project from start to finish. You always learn so much more by making something real.

Let your experience guide you! For example, I needed to play an MP3 in a LiveView when a user clicks an icon yesterday. My first approach that I imagined used a React-style solution where I’d conditionally render audio tags based on if a certain file existed on another host … totally wrong. I read some docs, did some rubber ducking with an LLM, and found out you can solve this super easy with 2 HTML attributes and a few lines of JavaScript to interop with the Audio WebAPI.

~H"""
<div>
  <%= if @audio_url do %>
    <!-- Don't forget to include a unique `id` attribute or the hook will have undefined behavior! -->
    <div
      id="audio-button"
      data-audio-url={@audio_url}
      phx-hook="PlayAudio"
    >
      🎵 Play Audio
    </div>
  <% end %>
</div>
"""
let Hooks = {}

Hooks.PlayAudio = {
  mounted() {
    this.el.addEventListener("click", () => {
      const audioUrl = this.el.getAttribute("data-audio-url")
      if (audioUrl) {
        const audio = new Audio(audioUrl);
        audio.play().catch((error) => console.error("Audio playback failed:", error))
      }
    })
  }
}

let liveSocket = new LiveSocket("/live", Socket, { hooks: Hooks })
liveSocket.connect()

I probably never would have learned how to put all these little pieces together if I had stuck with book learning and watching lectures. Just jump right in to it. It’s more fun this way in my opinion. The Elixir community is very kind and helpful in my experience. It’s a great place to “learn in public.” You can always ask questions on this forum and post your projects when you’ve got a cool demo.

codeanpeace

codeanpeace

If you like a choose your own adventure approach, run and play around with open source sample apps like TodoTrek and LiveBeats to find the dynamic interactions that interest you. Then poke around their respective repos and use those interactions as a treasure map to direct your spelunking.

You can use the phx-change binding on the first input to send an event back to the socket that updates an assign used to populate the second input that depends on the first.

Here’s an example I made a while back that shows how to select organization → select user belonging to selected organization:

https://github.com/codeanpeace/live_cal/commit/300d7843a31f28a31678db0cf3dd81722656bec8

arcyfelix

arcyfelix

I can second that. Their courses are fantastic!

z7ealth

z7ealth OP

Thanks everyone!

Update: I switched to a NextJS frontend, after a week of using it, i went back to Phoenix :rofl:

Holy moly, now i just don’t mind if i spend 2 days on a select

:v

— All posts loaded —

Where Next? Top

Trending in Questions Top

katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
achenet
Hello, I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind. However, when I launch mix phx.server, I get an error...
New
bradley
I really like the adapter patterns that ecto, nebulex, waffle, etc. use and would love find something similar for a key management servic...
New
Cxx-mlr
I’m working on a small exercise involving update_in/3, and I came up with this solution: data = %{ name: "Periodic Table", category:...
New
unaware8150
Hello folks! So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
ChrisAmelia
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication): toke...
New
dillonoconnor
Is there any way to avoid the Hologram compiler running when using iex? It seems like the front-end code could potentially be disregarded...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews