diff --git a/lib/philomena_web/controllers/image/comment_controller.ex b/lib/philomena_web/controllers/image/comment_controller.ex index e3f15713..e1000269 100644 --- a/lib/philomena_web/controllers/image/comment_controller.ex +++ b/lib/philomena_web/controllers/image/comment_controller.ex @@ -53,9 +53,7 @@ defmodule PhilomenaWeb.Image.CommentController do Images.reindex_image(conn.assigns.image) UserStatistics.inc_stat(conn.assigns.current_user, :comments_posted) - conn - |> put_flash(:info, "Comment created successfully.") - |> redirect(to: Routes.image_path(conn, :show, image) <> "#comment_#{comment.id}") + index(conn, %{"comment_id" => comment.id}) _error -> conn diff --git a/lib/philomena_web/templates/image/comment/_form.html.slime b/lib/philomena_web/templates/image/comment/_form.html.slime index a504c3ea..5cb6b9e4 100644 --- a/lib/philomena_web/templates/image/comment/_form.html.slime +++ b/lib/philomena_web/templates/image/comment/_form.html.slime @@ -1,4 +1,6 @@ -= form_for @changeset, Routes.image_comment_path(@conn, :create, @image), fn f -> +- options = if(assigns[:remote], do: [data: [remote: "true"], id: "js-comment-form"], else: []) + += form_for @changeset, Routes.image_comment_path(@conn, :create, @image), options, fn f -> = if @changeset.action do .alert.alert-danger p Oops, something went wrong! Please check the errors below. diff --git a/lib/philomena_web/templates/image/show.html.slime b/lib/philomena_web/templates/image/show.html.slime index 631563dd..e1195272 100644 --- a/lib/philomena_web/templates/image/show.html.slime +++ b/lib/philomena_web/templates/image/show.html.slime @@ -19,7 +19,7 @@ = render PhilomenaWeb.BanView, "_ban_reason.html", conn: @conn - @image.commenting_allowed -> - = render PhilomenaWeb.Image.CommentView, "_form.html", image: @image, changeset: @comment_changeset, conn: @conn + = render PhilomenaWeb.Image.CommentView, "_form.html", image: @image, changeset: @comment_changeset, remote: true, conn: @conn - true ->