add templete

This commit is contained in:
Rueshyna 2012-11-28 18:12:21 +08:00
parent 796dcc4dc6
commit 254a81fa5d
1 changed files with 45 additions and 0 deletions

View File

@ -191,7 +191,35 @@
<%= wjf.file_field :file %> <%= wjf.file_field :file %>
<% end %> <% end %>
--> -->
<table class="table table-condensed">
<thead>
<tr>
<th>File</th>
<th>File Name</th>
<th class="span1"></th>
</tr>
</thead>
<tfoot>
<tr>
<td style="text-align:center" colspan="3">
<div id='add_plugin_file' class="info_input plugin_files_block">
<%= hidden_field_tag 'plugin_file_field_count', @writing_journal.writing_journal_files.count %>
<a class="add"><span class="btn btn-primary btn-small"><i class="icon-plus icon-white"></i> add </span></a>
</div>
</td>
</tr>
</tfoot>
<tbody>
<% @writing_journal.writing_journal_files.each_with_index do |writing_journal_file, i| %>
<%= f.fields_for :writing_journal_files, writing_journal_file do |f| %>
<%= render :partial => 'form_file', :object => writing_journal_file, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
</tbody>
</table>
</li> </li>
</div>
<div class="s_grid_con s_form">
<li class="s_grid_row"> <li class="s_grid_row">
<%= f.text_area :note, size: "20x2", plcaeholder: "Note", class: "s_grid_6 s_grid"%> <%= f.text_area :note, size: "20x2", plcaeholder: "Note", class: "s_grid_6 s_grid"%>
</li> </li>
@ -213,5 +241,22 @@
</script> </script>
<%= javascript_include_tag "archive_plugin_form" %>
<script>
$('#add_plugin_file a.add').live('click', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_add_plugin_files", "g");
$(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parents('table').append(("<%= escape_javascript(add_attribute 'form_file', f, :writing_journal_files) %>").replace(old_id, new_id));
});
$('.add_plugin_files_block a.delete').live('click', function(){
$(this).parents('.list_item').remove();
});
$('.action a.remove_existing_record').live('click', function(){
$(this).next('.should_destroy').attr('value', 1);
$("tr#add_plugin_file_" + $(this).prev().attr('value')).hide();
});
</script>