Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elixir phoenix Logout link does not work

I have the following Logout link in my app, but when i click on it, it does not do anything.

<li class="nav-item">
  <%= link "Logout", to: session_path(@conn, :delete), method: :delete, class: "nav-link" %>
</li>

The html element the above code generates is

<li class="nav-item">
  <form action="/logout" class="link" method="post">
    <input name="_method" type="hidden" value="delete">
    <input name="_csrf_token" type="hidden" value="GiA4JANYN10+JQhfUgIEARxZCRIEAAAUijC25v5Kj8j7KI6qrOtv==">
    <a data-submit="parent" href="#">Logout</a>
  </form>
</li>

Does anyone see anything obviously wrong here that the logout link would not do anything when clicked?

brunch-config.js

javascripts: {
 joinTo: {
   "js/app.js": /^(web\/static\/js)/,
   "js/jquery-ujs.js.js": ["web/static/vendor/js/jquery-ujs.js.js"],
   "js/jquery.js": ["web/static/vendor/js/jquery.js"]
 },
 ...
like image 862
Pratik Khadloya Avatar asked Sep 25 '22 20:09

Pratik Khadloya


1 Answers

I believe that the code that is responsible for handling such cases is in the phoenix_html package's js file so you need to make sure you have added this package to mix and have the following line in your app.js file uncommented:

import "deps/phoenix_html/web/static/js/phoenix_html"

like image 189
NoDisplayName Avatar answered Nov 15 '22 09:11

NoDisplayName