collegeimprovements

collegeimprovements

JS not working for Phoenix

Any JS command, push_patch etc are not working and giving the following error:

live_socket.js:377 Uncaught TypeError: Cannot read properties of null (reading 'el')
    at LiveSocket.replaceMain (live_socket.js:377:60)
    at live_socket.js:748:12
    at LiveSocket.withPageLoading (live_socket.js:718:23)
    at LiveSocket.historyRedirect (live_socket.js:747:10)
    at Object.exec_navigate (js.js:58:21)
    at js.js:17:22
    at Array.forEach (<anonymous>)
    at js.js:16:40
    at Array.forEach (<anonymous>)
    at Object.exec (js.js:12:14)

I’m having the following error when I try to apply push_patch.

** (ArgumentError) cannot push_patch/2 to 
%URI{authority: nil, fragment: nil, host: "localhost", path: "/events/de98359c-9b32-4197-82f0-fa7b2e283646", port: 4000, query: nil, scheme: "http", userinfo: nil}
because the given path does not point to the current root view APIWeb.Ev.Index`

Relevant handle_event code:

 @impl true
  def handle_event("debug", %{"event" => event_guid} = _params, socket) do
    socket
    |> push_patch(to: "/events/#{event_guid}")
    |> noreply_socket()
  end

push_navigate works but it takes 10 seconds while normal anchor tag just works instantaneously.

What can I try here ?

LiveView Version: 0.18.16
Phoenix Version: 1.16

Marked As Solved

mcrumm

mcrumm

Phoenix Core Team

Someone reported a similar issue recently and it was resolved by making sure all dependencies were up-to-date, including making sure to rebuild client assets:

Does any of that advice apply in your case?

Also Liked

mcrumm

mcrumm

Phoenix Core Team

Here are the rules around LiveView navigation:

  1. Patch is only for modifying the URL and staying on the current LiveView process. It only works for links to the current LiveView.

  2. Navigate is to move between routes in the same live_session block in your Router. It can also be used to tear down the current LiveView process and start a new one.

Note that if you do not have any explicit live_session blocks in your Router then all live routes are in the default live session.

  1. Href is for everything else.

The slowness you are experiencing with navigate is all of the extra round-trips the client must do because the server returns errors on the invalid navigate call.

Edit: early submit :slight_smile:

collegeimprovements

collegeimprovements

I nuked all the deps and reinstalled them and it fixed it.
Thanks a lot for your help :blush:

Where Next?

Popular in Questions Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
nobody
How to bind a phoenix app to a specific ip address? could not find anything about that, nowhere, unfortunately, but for me this is quite...
New
JulienCorb
I am trying to implement my new.html.eex file to create new posts on my website. new.html.eex: &lt;h1&gt;Create Post&lt;/h1&gt; &lt;%= ...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: The documentation above suggests that while ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
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

Other popular topics Top

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
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 41539 114
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
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
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
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

We're in Beta

About us Mission Statement