diff --git a/app/controllers/public/comment_controller.rb b/app/controllers/public/comment_controller.rb index f8d27b6..5cf52dd 100644 --- a/app/controllers/public/comment_controller.rb +++ b/app/controllers/public/comment_controller.rb @@ -154,7 +154,7 @@ class CommentController < ApplicationController render :json => { :ok => false, :render_target => 'form', - :html => render_to_string(:partial => 'comment_form', :object => @comment, :locals => {:comment => @comment, :display_link => false, :edition_mode => true}) + :html => render_to_string(:partial => 'comment_form', :object => @comment, :locals => {:comment => @comment, :display_link => false, :edition_mode => true, :show_form => true}) } end end diff --git a/app/views/comment/_comment_form.rhtml b/app/views/comment/_comment_form.rhtml index a9a8982..7ddd655 100644 --- a/app/views/comment/_comment_form.rhtml +++ b/app/views/comment/_comment_form.rhtml @@ -10,8 +10,8 @@ if (d.hasClass('closed')) { d.removeClass('closed'); d.addClass('opened'); - d.find('input[name=comment[title]], textarea').val(''); - d.find('.comment_form input[name=comment[<%= focus_on %>]]').focus(); + d.find('input[name=\'comment[title]\'], textarea').val(''); + d.find('.comment_form input[name=\'comment[<%= focus_on %>]\']').focus(); }"> <%= content_tag('a', '', :name => 'comment_form') + _('Post a comment') %> @@ -61,10 +61,7 @@ function check_captcha(button, confirm_action) { <% remote_form_for(:comment, comment, :url => {:profile => profile.identifier, :controller => 'comment', :action => (edition_mode ? 'update' : 'create'), :id => (edition_mode ? comment.id : @page.id)}, :html => { :class => 'comment_form' } ) do |f| %> - <% if comment && comment.errors.any? %> - <%= error_messages_for :comment %> - - <% end %> + <%= error_messages_for :comment %> <%= hidden_field_tag(:confirm, 'false') %> diff --git a/public/javascripts/application.js b/public/javascripts/application.js index b8b4d75..eea2773 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -752,7 +752,9 @@ function save_comment(button) { } else if(data.render_target == 'form') { //Comment with errors - $(button).parents('.page-comment-form').html(data.html); + var page_comment_form = $(button).parents('.page-comment-form'); + $.scrollTo(page_comment_form); + page_comment_form.html(data.html); } else if($('#' + data.render_target).size() > 0) { //Comment of reply @@ -768,6 +770,7 @@ function save_comment(button) { }); form.find('.errorExplanation').remove(); + $.colorbox.close(); } @@ -784,7 +787,6 @@ function save_comment(button) { display_notice(data.msg); } - $.colorbox.close(); close_loading(); post_comment_box.removeClass('opened'); post_comment_box.addClass('closed'); -- libgit2 0.21.2