$(document).ready(function() { $('.main-forms .add-on').tooltip(); $(document).on('click', '#add_author', function(){ var new_id = $(this).prev().attr('value'); var old_id = new RegExp("new_authors", "g"); var on = $('.language-nav li.active').index(); var le = $(this).parent('.add-btn-box').prev('.add-target-box').children('.start-line').length; $(this).prev().attr('value', parseInt(new_id) + 1); $(this).parent().siblings('.add-target-box').append(("<%= escape_javascript(add_attribute 'form_author', (f rescue nil), :journal_paper_authors) %>").replace(old_id, new_id)); $(this).parent('.add-btn-box').prev('.add-target-box').children('.start-line').eq(le).children('.input-append').find('.tab-content').each(function() { $(this).children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active'); }); formTip(); }); $(document).on('click', '.delete_file', function(){ $(this).parents('.input-prepend').remove(); }); $(document).on('click', '.remove_existing_record', function(){ if(confirm("<%= I18n.t(:sure?)%>")){ $(this).children('.should_destroy').attr('value', 1); $(this).parents('.start-line').hide(); } }); });