fixed adding.

This commit is contained in:
Harry Bomrah 2013-03-04 16:21:35 +08:00
parent 9a32732ae4
commit d4392c8d56
2 changed files with 22 additions and 16 deletions

View File

@ -51,6 +51,23 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ //
this.initializeJournalPapers.addpaper = function(){ // to open add pages in journal papers page this.initializeJournalPapers.addpaper = function(){ // to open add pages in journal papers page
var bindHandlers = function(){ // to bind handlers for add page var bindHandlers = function(){ // to bind handlers for add page
o.simple_drop_down(); o.simple_drop_down();
$('#add_plugin_file a.add').click(function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_writing_journal_files", "g");
$(this).prev().attr('value', parseInt(new_id) + 1);
var x = get_html(old_id,new_id);
var newfield = $(x);
$(this).parents('table').append(newfield);
newfield.find('.action a.delete').click(function(){
newfield.remove();
});
return false;
});
$('.action a.remove_existing_record').click(function(){
$(this).next('.should_destroy').attr('value', 1);
$("tr#add_plugin_file_" + $(this).prev().attr('value')).hide();
});
} }
bindHandlers(); bindHandlers();
} }

View File

@ -179,7 +179,7 @@
<td colspan="3"> <td colspan="3">
<div id='add_plugin_file' class="info_input plugin_files_block s_action"> <div id='add_plugin_file' class="info_input plugin_files_block s_action">
<%= 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 setting_btn thmc1 thmtxt w1 hh2 hp" href=""><i class="icon-plus icon-white"></i> add</a> <a class="add setting_btn thmc1 thmtxt w1 hh2 hp" href="#"><i class="icon-plus icon-white"></i> add</a>
</div> </div>
</td> </td>
</tr> </tr>
@ -222,21 +222,10 @@
</script> </script>
<script> <script>
$('#add_plugin_file a.add').click(function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_writing_journal_files", "g");
$(this).prev().attr('value', parseInt(new_id) + 1);
var newfield = $(("<%= escape_javascript(add_attribute 'form_file', f, :writing_journal_files) %>").replace(old_id, new_id));
$(this).parents('table').append(newfield);
newfield.find('.action a.delete').click(function(){
newfield.remove();
});
return false;
});
$('.action a.remove_existing_record').click(function(){
$(this).next('.should_destroy').attr('value', 1); var get_html = function(old_id,new_id){
$("tr#add_plugin_file_" + $(this).prev().attr('value')).hide(); return ("<%= escape_javascript(add_attribute 'form_file', f, :writing_journal_files) %>").replace(old_id, new_id)
}); }
</script> </script>