can add multiple file

This commit is contained in:
Rueshyna 2012-11-29 11:21:05 +08:00 committed by chris
parent 5a9d9151d9
commit 4a0cc61852
1 changed files with 7 additions and 13 deletions

View File

@ -185,26 +185,20 @@
<span class="icon-plus input_append"></span> <span class="icon-plus input_append"></span>
<ul> <ul>
<li class="s_grid_row"> <li class="s_grid_row">
<div> <%= label_tag("", "Full Text", class: "s_grid_2 s_grid") %></div> <table>
<!--
<%= f.fields_for :writing_journal_files, @writing_journal do |wjf| %>
<%= wjf.file_field :file %>
<% end %>
-->
<table class="table table-condensed">
<thead> <thead>
<tr> <tr>
<th>File</th> <th class="s_grid_2 s_grid">File</th>
<th>File Name</th> <th class="s_grid_2 s_grid">File Name</th>
<th class="span1"></th> <th><span id='add_plugin_file' class="icon-plus input_append"></span></th>
</tr> </tr>
</thead> </thead>
<tfoot> <tfoot>
<tr> <tr>
<td style="text-align:center" colspan="3"> <td>
<div id='add_plugin_file' class="info_input plugin_files_block"> <div id='add_plugin_file' class="info_input plugin_files_block">
<%= hidden_field_tag 'plugin_file_field_count', @writing_journal.writing_journal_files.count %> <%= 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> <a class="add"><span><i class="icon-plus icon-white"></i> add </span></a>
</div> </div>
</td> </td>
</tr> </tr>
@ -245,7 +239,7 @@
<script> <script>
$('#add_plugin_file a.add').live('click', function(){ $('#add_plugin_file a.add').live('click', function(){
var new_id = $(this).prev().attr('value'); var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_add_plugin_files", "g"); var old_id = new RegExp("new_writing_journal_files", "g");
$(this).prev().attr('value', parseInt(new_id) + 1); $(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)); $(this).parents('table').append(("<%= escape_javascript(add_attribute 'form_file', f, :writing_journal_files) %>").replace(old_id, new_id));
}); });