I\'ve used Phoenix\'s built in gen.HTML to generate a simple view but it\'s not working
<%= link \"Delete\", to: event_path(@conn, :delete, event), method
I recently had the same issue, it turns out that I had accidentally deleted the <script src="<%= static_path(@conn, "/js/app.js") %>"></script>
from my layout.html.eex
file. Adding it back fixed the issue.
For anyone else hitting this I had a completely different problem that manifested itself in the same way, will drop this here in case it helps:
It turns out I accidentally deleted import "phoenix_html"
from the app.js file mistaking it for being part of the generated boilerplate, adding it back fixed my issue.
Edit: This happens to be known issue. Here is the fix:
In brunch-config.js
autoRequire: {
"js\\app.js": ["web/static/js/app"]
}
Source
While not the particular solution to OP's issue, this error can also arise if you place
<script src="<%= static_path(@conn, "/js/app.js") %>"></script>
in the the wrong place in app.html.eex
. (For example inside <head>
instead of at the end of the body)
For later versions of Phoenix, if you view the app.js file within priv/static/js/app.js
you'll notice a comment that references a link to a raw github js file. This small snippet of Javascript contains important code to ensure that the delete
link helpers actually work correctly.