The page reload every time I click on input

Hi everyone! I’m beginner in Phoenix framework and Elixir. So, I’m with problem when I click on input my page reload. As you can see in the gif:

elixir

controller(topic_controller.ex)

defmodule DiscussWeb.TopicController do
  use DiscussWeb, :controller
  alias Discuss.Topic
  alias  Discuss.Repo
  def index(conn, _params) do
    topics = Repo.all(Topic)
    render conn, "index.html", topics: topics

  end
  def new(conn, _params) do
    changeset = Topic.changeset(%Topic{}, %{})
    render conn, "new.html", changeset: changeset
  end

  def create(conn,  %{ "topic" => topic }) do
    changeset = Topic.changeset(%Topic{}, topic)

   case Repo.insert(changeset) do
    {:ok,  _post } ->
      conn
      |> put_flash(:info, "Topic Created")
      |> redirect(to: Routes.topic_path(conn, :index))
    {:error, changeset } -> render conn, "new.html", changeset: changeset

   end

  end
end

my form(new.html.eex)

<%= form_for @changeset, Routes.topic_path(@conn, :create), fn f -> %>
  <div class="form-group">
    <%= text_input f, :title, placeholder: "Title", class: "form-control" %>
    <%= error_tag f, :title %>
  </div>

  <%= submit "Save Topic", class: "btn btn-primary" %>
<% end %>

my router(router.ex)

defmodule DiscussWeb.Router do
  use DiscussWeb, :router

  pipeline :browser do
    plug :accepts, ["html"]
    plug :fetch_session
    plug :fetch_flash
    plug :protect_from_forgery
    plug :put_secure_browser_headers
  end

  pipeline :api do
    plug :accepts, ["json"]
  end

  scope "/", DiscussWeb do
    pipe_through :browser

    get "/", TopicController, :index
    get "/topics/new", TopicController, :new
    post "/topics", TopicController, :create
  end

  # Other scopes may use custom stacks.
  # scope "/api", DiscussWeb do
  #   pipe_through :api
  # end

  # Enables LiveDashboard only for development
  #
  # If you want to use the LiveDashboard in production, you should put
  # it behind authentication and allow only admins to access it.
  # If your application does not have an admins-only section yet,
  # you can use Plug.BasicAuth to set up some basic authentication
  # as long as you are also using SSL (which you should anyway).
  if Mix.env() in [:dev, :test] do
    import Phoenix.LiveDashboard.Router

    scope "/" do
      pipe_through :browser
      live_dashboard "/dashboard", metrics: DiscussWeb.Telemetry
    end
  end
end

Can you help me please?

Towards the beginning of the video, when the cursor passes over some text, all the text appears to highlight - as if it’s all part of one runaway <a> tag…

Here’s a demo - focusing on the form field triggers the behavior from the runaway link in the header tag

https://jsfiddle.net/3a0r1gcq/

1 Like

Thanks, my friend. I forget to close the tag on the header. Now I fixed it