sevensidedmarble

sevensidedmarble

There should be a built in hook for running exec JS commands

All the pieces are there to execute arbitrary JS commands from the server. You can put them on a data property and call them from the client with execJs. But you can’t just do this arbitrarily. You need to make a new hook, dispatch the custom calls to it, and have that hook call execJs.

Wouldn’t it be a lot simpler if LiveView JS just shipped with a hook that could execute any JS commands serialized onto an attribute from the server (ie handle_events)?

I’m aware you can build this yourself without too much trouble but why not just ship this? It would allow anyone to call the full range of JS command stuff from handle_events right out of the box.

Most Liked

josevalim

josevalim

Creator of Elixir

Please keep in mind these solutions most likely bypass any future CSP you put in place, making it more vulnerable to XSS attacks. I’d not recommend it as a general solutions and, if someone wants to go down this road, please be aware of the security implications.

sevensidedmarble

sevensidedmarble

Well how does the current JS command system work with CSP? There is nothing out of the box to generate nonces for the commands or something is there?

Where Next?

Popular in Proposals: Ideas Top

sbennett33
When building a component library, it is often useful to give users the ability to customize the underlying element or component to use. ...
New
virinchi_cv
The Problem Phoenix 1.8 comes aggressively coupled with Daisy UI, a decision which many developers in the community have had mixed feelin...
New
moacirbishopcamata
Good morning to the Elixir team. Please excuse me if I’m commenting in the wrong place; please indicate where I should discuss this. I ...
New
beno
There appears to be no way to escape whitespace in word lists, so sigil_w (and sigil_W) can only be used for lists of single words. Of co...
New
pelopo
Hi, Oficial docs got this wonderful feature to download the ePub version that we can chuck to our kindles and read it. Now we are in the...
New
jakeprem
Goal: To make JS.patch and JS.navigate more interoperable with JS.push. Scenario: Imagine making a reusable Phoenix component and you wa...
New
dkuku
This is a proposal to make the map key mismatch errors a bit better: Every time I have a typo It’s very challenging for me even when I u...
New
lemaster
Currently we have stream_insert and stream that can either add new items to a stream or update existing items if they are already present...
New
munksgaard
I’m copying and pasting this issue from @Terbium-135 here verbatim, because I would be interested in such a feature as well, and because ...
New
sevensidedmarble
I have a very simple suggestion: the generated config/dev.exs file should read from PORT at compile time to set the endpoints port. If ...
New

Other popular topics Top

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
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
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
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 47930 226
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
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

Latest on Elixir Forum

We're in Beta

About us Mission Statement