add back buton in relation page

This commit is contained in:
Rueshyna 2012-12-05 18:24:50 +08:00 committed by chris
parent b4a99e58cf
commit 6d08ca996f
3 changed files with 8 additions and 5 deletions

View File

@ -16,18 +16,18 @@ class Desktop::CoAuthorRelationsController < ApplicationController
end end
def new def new
@new_relation = CoAuthorRelation.new @co_author_relation = CoAuthorRelation.new
end end
def create def create
@new_relation = CoAuthorRelation.new(params[:co_author_relation]) @co_author_relation = CoAuthorRelation.new(params[:co_author_relation])
@co_author_relations = CoAuthorRelation.all @co_author_relations = CoAuthorRelation.all
if @new_relation.save if @co_author_relation.save
newv = render_to_string partial: "show_form", object: @co_author_relations newv = render_to_string partial: "show_form", object: @co_author_relations
render json: {success: true, msg: "New Relation successfully saved!", newvalue: newv}.to_json render json: {success: true, msg: "New Relation successfully saved!", newvalue: newv}.to_json
else else
error_msg = @new_relation.errors.full_messages.join("<br />") error_msg = @co_author_relation.errors.full_messages.join("<br />")
render json: {success: false, msg: error_msg}.to_json render json: {success: false, msg: error_msg}.to_json
end end
end end

View File

@ -1,2 +1,5 @@
<% if not @co_author_relation.new_record? %>
<%= submit_tag "Cancel", :type => "button", class: "bt-cancel ini_input hp hh2 thmadm thmtxt" %>
<% end %>
<%= f.text_field :relation %> <%= f.text_field :relation %>
<%= f.submit "Save" %> <%= f.submit "Save" %>

View File

@ -1,3 +1,3 @@
<%= form_for(@new_relation , url: desktop_co_author_relations_path, html:{"form-type"=>"ajax_form", "callback-method"=>"coauthorRelationForm"} ) do |f| %> <%= form_for(@co_author_relation, url: desktop_co_author_relations_path, html:{"form-type"=>"ajax_form", "callback-method"=>"coauthorRelationForm"} ) do |f| %>
<%= render partial: 'desktop/co_author_relations/form' , locals: {:f => f}%> <%= render partial: 'desktop/co_author_relations/form' , locals: {:f => f}%>
<% end %> <% end %>