new type fixed

This commit is contained in:
Harry Bomrah 2012-12-03 15:44:26 +08:00 committed by chris
parent 5d6dd8cded
commit 49d1ca6997
5 changed files with 18 additions and 11 deletions

View File

@ -281,7 +281,7 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ //
})
return false;
})
$("a.bt-delete").click(function(){
$("div[container=true]").unbind(".delete").on("click.delete","a.bt-delete",function(){
var delurl = $(this).attr("href");
var parent = $(this).parent().parent();
o.confirm({
@ -346,6 +346,7 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ //
this.initializeJournalPapers.coauthorRelationForm = function(data){
if(data.success){
o.notify(data.msg,"success");
$("#co_author_relation_table tbody").prepend(data.newvalue);
}else{
o.notify(data.msg,"alert");
}

View File

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

View File

@ -1,6 +1,6 @@
<% @co_author_relations.each do |co_author_relation| %>
<%# @co_author_relations.each do |co_author_relation| %>
<tr>
<td><%= co_author_relation.relation %></td>
<td><%= link_to 'Destroy', desktop_co_author_relation_path(co_author_relation), confirm: 'Are you sure?', method: :delete %></td>
<td><%= show_form.relation %></td>
<td><%= link_to 'Destroy', desktop_co_author_relation_path(show_form), confirm: 'Are you sure?', method: :delete, :class=>"bt-delete" %></td>
</tr>
<% end %>
<%# end %>

View File

@ -2,13 +2,15 @@
<%= render 'form' %>
<table>
<table id="co_author_relation_table">
<thead>
<tr>
<th>Relation</th>
<th></th>
<th></th>
</tr>
<%= render 'show_form'%>
</thead>
<tbody>
<%= render :partial => 'show_form', :collection => @co_author_relations %>
</tbody>
</table>

View File

@ -2,6 +2,7 @@
<%= link_to "New Co-Author", new_desktop_co_author_path, :class=>"bt-co-author" %>
<%= link_to "New Type", desktop_co_author_relations_path, :class=>"bt-new-type" %>
<table>
<thead>
<tr>
<th>Name</th>
<th>EMail</th>
@ -10,7 +11,8 @@
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<% @co_authors.each do |co_author| %>
<tr>
<td><%= co_author.co_author %></td>
@ -20,5 +22,6 @@
<td><%= link_to 'Destroy', desktop_co_author_path(co_author), method: :delete, confirm: 'Are you sure?', :class=>"bt-delete" %></td>
</tr>
<% end %>
</tbody>
</table>
<br />