aarroisi

aarroisi

Elements are Removed by LiveView

Hi, I want to ask is it possible to turn off some elements from being updated by LiveView? I have a use case like the following:

I use Trix Editor (https://trix-editor.org/) in my project and it’s working perfectly with “Dead” view, / the regular controller view. But when I try to use LiveView for pages that incorporate this editor, LiveView seems to remove the elements generated by the library.

To give you some context, Trix editor requires you only to insert one custom HTML tag () and the library generates the actual editor after the page is rendered. When we interact with the editor, Trix will automatically send the generated HTML strings to a target input element in the form, which actually is hidden from the UI. After we’ve done using the editor and try to save, the actual data sent is the one inside the target input element, not inside the Trix editor itself.

When I try to use it inside a LiveView, it somehow removes the editor from the DOM after updated. The flow is something like this:

  1. HTML loaded, containing tag
  2. Trix editor JS executed, generating the editor
  3. The socket fills the LiveView component containing the form
  4. The form target input field is populated from the existing data
  5. Trix editor content is updated (by the tw-way communication between Trix editor and target input field)
  6. Live view detects the update, Trix editor is destroyed.

My question is, is there any way to exclude some part of the html from being updated by the LiveView? The only communication the LiveView needs in this case is from the Trix editor’s target element to the stateful process and vice versa, but no need to try to update and the state of the editor itself.

Marked As Solved

arcanemachine

arcanemachine

Also Liked

aarroisi

aarroisi

Thanks! That’s exactly what I need and it solves the problem.

Last Post!

aarroisi

aarroisi

Thanks! That’s exactly what I need and it solves the problem.

Where Next?

Popular in Questions Top

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New

Other popular topics Top

jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 42533 114
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

We're in Beta

About us Mission Statement