<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="153978" data-post-id="153978">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="venomnert" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/venomnert/120/13305_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  venomnert
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hey <a class="mention" href="/u/mindok" rel="nofollow">@mindok</a> I believe this is it. Here is what I’m getting.</p>
<p><code>assets/js/app.js</code></p>
<pre data-code-wrap="elixir"><code class="lang-elixir">import css from "../css/app.css"
import "phoenix_html"

import {Socket} from "phoenix"
import LiveSocket from "phoenix_live_view"

let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content");
let liveSocket = new LiveSocket("/live", Socket, {params: {_csrf_token: csrfToken}});

console.log(Socket, "SOCKET");
console.log(liveSocket.connect());
</code></pre>
<p>In normal browsing mode I don’t get any console, however, when I empty cache and hard reload or visit incognito mode I get the following log in phoenix</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">[info] REFUSED CONNECTION TO Phoenix.LiveView.Socket in 218µs
  Transport: :websocket
  Serializer: Phoenix.Socket.V2.JSONSerializer
  Connect Info: %{}
  Parameters: %{"_csrf_token" =&gt; "O30ePiBaAy8jIXIqcxB1OEE1EDcIJyt4jLDpf3iekE6lFaMv-ljdWVF7", "vsn" =&gt; "2.0.0"}
[error] LiveView was not configured to use session. Do so with:

1) Find `plug Plug.Session, ...` in your endpoint.ex and move the options `...` to a module attribute:

    @session_options [
      ...
    ]

2) Change the `plug Plug.Session` to use said attribute:

    plug Plug.Session, @session_options

3) Also pass the `@session_options` to your LiveView socket:

    socket "/live", Phoenix.LiveView.Socket,
      websocket: [connect_info: [session: @session_options]]

4) You should define the CSRF meta tag inside the in &lt;head&gt; in your layout: 

    &lt;%= csrf_meta_tag() %&gt;

5) Then in your app.js:

    let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content");
    let liveSocket = new LiveSocket("/live", Socket, {params: {_csrf_token: csrfToken}});

[info] REFUSED CONNECTION TO Phoenix.LiveView.Socket in 204µs
  Transport: :websocket
  Serializer: Phoenix.Socket.V2.JSONSerializer
  Connect Info: %{}
  Parameters: %{"_csrf_token" =&gt; "O30ePiBaAy8jIXIqcxB1OEE1EDcIJyt4jLDpf3iekE6lFaMv-ljdWVF7", "vsn" =&gt; "2.0.0"}
</code></pre>
<p>And i’m able to see JS console as well. But when I do a normal refresh, my assets get’s cached and i don’t see the JS console anymore.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="153978" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/liveview-form-debugging-phx-submit-not-getting-triggered/27423/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-153978" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="153978"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="153988" data-post-id="153988">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="mindok" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/mindok/120/13538_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  mindok
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hmmm. So we know where the problem is. I can’t help much with this - I don’t know the asset reloading area well enough to debug without it in front of me. Maybe you could start a new topic around reloading app.js.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="153988" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/liveview-form-debugging-phx-submit-not-getting-triggered/27423/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-153988" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="153988"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="153989" data-post-id="153989">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="venomnert" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/venomnert/120/13305_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  venomnert
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Sounds good, I will check it out. Once again thanks for you help <img src="https://forum.elixirforum.com/images/emoji/apple/smiley.png?v=15" title=":smiley:" class="emoji" alt=":smiley:" loading="lazy" width="20" height="20"> <img src="https://forum.elixirforum.com/images/emoji/apple/+1.png?v=15" title=":+1:" class="emoji" alt=":+1:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="153989" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/liveview-form-debugging-phx-submit-not-getting-triggered/27423/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-153989" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="153989"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #13"></div>
  </section>
</div>
    <div class="postbit" id="154129" data-post-id="154129">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="venomnert" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/venomnert/120/13305_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  venomnert
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hey <a class="mention" href="/u/mindok" rel="nofollow">@mindok</a> I have resolved the issue.</p>
<p>The problem was with this code <code>socket "/live", Phoenix.LiveView.Socket, websocket: true</code> within the <code>endpoint.ex</code></p>
<p>I had to provide it the same session info that was provided to <code>plug Plug.Session</code>.</p>
<p>I was able to solve this after carefully reading Phoenix error messaging, which was clear and concise <img src="https://forum.elixirforum.com/images/emoji/apple/+1/5.png?v=15" title=":+1:t5:" class="emoji" alt=":+1:t5:" loading="lazy" width="20" height="20"></p>
<p>Here are the following update:<br>
<code>contact_us/lib/contact_us_web/endpoint.ex</code></p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule ContactUsWeb.Endpoint do
  use Phoenix.Endpoint, otp_app: :contact_us
  @session_options [
    store: :cookie,
    key: "_contact_us_key",
    signing_salt: "piqiBzEh"
  ]

  socket "/live", Phoenix.LiveView.Socket,
  websocket: [connect_info: [session: @session_options]]

  socket "/socket", ContactUsWeb.UserSocket,
    websocket: true,
    longpoll: false

  # Serve at "/" the static files from "priv/static" directory.
  #
  # You should set gzip to true if you are running phx.digest
  # when deploying your static files in production.
  plug Plug.Static,
    at: "/",
    from: :contact_us,
    gzip: false,
    only: ~w(css fonts images js favicon.ico robots.txt)

  # Code reloading can be explicitly enabled under the
  # :code_reloader configuration of your endpoint.
  if code_reloading? do
    socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket
    plug Phoenix.LiveReloader
    plug Phoenix.CodeReloader
  end

  plug Plug.RequestId
  plug Plug.Telemetry, event_prefix: [:phoenix, :endpoint]

  plug Plug.Parsers,
    parsers: [:urlencoded, :multipart, :json],
    pass: ["*/*"],
    json_decoder: Phoenix.json_library()

  plug Plug.MethodOverride
  plug Plug.Head

  # The session will be stored in the cookie and signed,
  # this means its contents can be read but not tampered with.
  # Set :encryption_salt if you would also like to encrypt it.
  plug Plug.Session, @session_options

  plug ContactUsWeb.Router
end
</code></pre>
<p><code>contact_us/assets/js/app.js</code></p>
<pre data-code-wrap="elixir"><code class="lang-elixir">import css from "../css/app.css"
import "phoenix_html"

import {Socket} from "phoenix"
import LiveSocket from "phoenix_live_view"

let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content");
let liveSocket = new LiveSocket("/live", Socket, {params: {_csrf_token: csrfToken}});
liveSocket.connect()
</code></pre>
<p><code>contact_us/lib/contact_us_web/templates/layout/app.html.eex</code></p>
<pre data-code-wrap="elixir"><code class="lang-elixir">  &lt;head&gt;
    &lt;meta charset="utf-8"/&gt;
    &lt;%= csrf_meta_tag() %&gt;
    &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"/&gt;
    &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"/&gt;
    &lt;title&gt;ContactUs · Phoenix Framework&lt;/title&gt;
    &lt;link rel="stylesheet" href="&lt;%= Routes.static_path(@conn, "/css/app.css") %&gt;"/&gt;
    &lt;%= csrf_meta_tag() %&gt;
  &lt;/head&gt;
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="154129" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/liveview-form-debugging-phx-submit-not-getting-triggered/27423/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-154129" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="154129"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-solved cat-solved" title="Marked as solution"></div>
  </section>
</div>
    <div class="postbit" id="155373" data-post-id="155373">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="fklement" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/fklement/120/24995_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  fklement
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hi <a class="mention" href="/u/mindok" rel="nofollow">@mindok</a>, I’m currently struggling with nearly the same issue.<br>
And I receive an error in my console <code>Uncaught SyntaxError: Cannot use import statement outside a module</code><br>
I tried this already with Google Chrome and Safari.<br>
Do you know what I’m doing wrong here?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="155373" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/liveview-form-debugging-phx-submit-not-getting-triggered/27423/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-155373" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="155373"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #15"></div>
  </section>
</div>
    <div class="postbit" id="155378" data-post-id="155378">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="mindok" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/mindok/120/13538_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  mindok
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hi <a class="mention" href="/u/fklement" rel="nofollow">@fklement</a>,<br>
That’s an issue on the javascript side - not my area of expertise. However, I googled the error message and there are quite a few helpful suggestions out there - e.g. <a href="https://stackoverflow.com/questions/58211880/uncaught-syntaxerror-cannot-use-import-statement-outside-a-module-when-import" rel="noopener nofollow ugc">https://stackoverflow.com/questions/58211880/uncaught-syntaxerror-cannot-use-import-statement-outside-a-module-when-import</a>. See how you go with those, otherwise you will need to put your app.js up here for us to take a look.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="155378" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/liveview-form-debugging-phx-submit-not-getting-triggered/27423/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-155378" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="155378"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #16"></div>
  </section>
</div>
    <div class="postbit" id="155418" data-post-id="155418">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="fklement" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/fklement/120/24995_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  fklement
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I just solved it. Probably it was just too late yesterday and I was sitting too long in front of the computer <img src="https://forum.elixirforum.com/images/emoji/apple/smile.png?v=15" title=":smile:" class="emoji" alt=":smile:" loading="lazy" width="20" height="20"><br>
The problem was that I messed up the <code>webpack.config.js</code>. And therefore the <code>/js</code>/ parts were not copied correct to the statics folder.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="155418" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/liveview-form-debugging-phx-submit-not-getting-triggered/27423/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-155418" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="155418"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #17"></div>
  </section>
</div>
    <div class="postbit" id="195103" data-post-id="195103">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="larshei" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/larshei/120/20660_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  larshei
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Just found this after I had run into the same problem. The JS not being executed was a good hint.</p>
<p>I had chosen to use a CSS framework and replaced the original CSS/JS loading in the root template, but the original app.js is required to establish the socket connection.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="195103" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/liveview-form-debugging-phx-submit-not-getting-triggered/27423/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-195103" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="195103"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>