ruby on rails 3 - Everything works in this Ajax submission except for the notice -
the email still gets sent , delivered, still no flash message.
form:
<%= form_for :fb_comment, :url => update_reply_feedback_path, :html => { :id => "reply" }, :remote => true |f| %> <%= f.text_area :reply, :size => '66x7' %><br> <center><%= f.submit "send reply" %></center> <% end %> in layout file:
<%- flash.each |name, msg| -%> <%= content_tag :div, msg, :id => "flash_#{name}" %> <%- end -%> in controller:
def reply2_feedback ... flash.now[:notice] = 'reply sent.' respond_to |format| format.html {} format.js end end in application.js:
jquery.ajaxsetup({ 'beforesend': function(xhr) {xhr.setrequestheader("accept", "text/javascript")} }) $(document).ready(function() { $("#reply").submit(function() { $.post($(this).attr("action"), $(this).serialize(), null, "script"); return false; }) }) update_reply.js.erb:
$("#flash").html('<div class="notice_alert"><%= escape_javascript(flash.delete(:notice)) %></div>'); thank you.
try using
flash.now[:notice] = 'reply sent.' instead.
Comments
Post a Comment