问吧编辑的时候ajax局部刷新

This commit is contained in:
huang 2016-12-30 13:54:42 +08:00
parent 53cd3a197b
commit 912752d646
4 changed files with 7 additions and 8 deletions

View File

@ -245,15 +245,14 @@ class ForumsController < ApplicationController
# PUT /forums/1.json
def update
@forum = Forum.find(params[:id])
respond_to do |format|
if @forum.update_attributes(params[:forum])
format.js {render :text=> true}
format.js
format.html { redirect_to @forum, notice: l(:label_forum_update_succ) }
format.json { head :no_content }
else
flash.now[:error] = "#{l :label_forum_update_fail}: #{@forum.errors.full_messages[0]}"
format.js { render :text=> false}
format.js
format.html { render action: "edit" }
format.json { render json: @forum.errors, status: :unprocessable_entity }
end

View File

@ -5,12 +5,9 @@
<div class="cl"></div>
</div>
<div class="muban_popup_con mt15" >
<%= labelled_form_for @forum, :html => {:id => "forum_new"} do |f| %>
<%= labelled_form_for @forum, :html => {:id => "forum_new", :remote => true} do |f| %>
<%= render :partial => "forums/form", :locals => {:f => f} %>
<% end %>
<%#= form_tag({:controller => 'forums', :action => 'create'}, :method => 'post', :id => "forum_new") do |f| %>
<%# end %>
</div>
</div>

View File

@ -22,7 +22,9 @@
</div>
<div class="fl">
<%= render :partial => "memos/my_count_message" %>
<div id="my_count_message">
<%= render :partial => "memos/my_count_message" %>
</div>
<div class="homepageLeft-new" id="forum_right_bar">
<div class="wenba-rightbar">

View File

@ -0,0 +1 @@
$("#my_count_message").html('<%= escape_javascript( render :partial => 'memos/my_count_message') %>');