fix js for form

This commit is contained in:
Harry Bomrah 2014-11-28 18:43:58 +08:00
parent 5215d76382
commit 4a8a0df7da
1 changed files with 6 additions and 9 deletions

View File

@ -303,9 +303,8 @@
<%= link_to t('cancel'), get_go_back, :class=>"btn" %> <%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div> </div>
<script> <script>
$(document).ready(function() { $('.main-forms').find('.add-on').tooltip().end().on('click', '.trigger, .delete_file, .remove_existing_record', function() {
$('.main-forms .add-on').tooltip(); if($(this).hasClass('trigger')) {
$(document).on('click', '#add_file', function(){
var new_id = $(this).prev().attr('value'); var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_journal_paper_files", "g"); var old_id = new RegExp("new_journal_paper_files", "g");
var on = $('.language-nav li.active').index(); var on = $('.language-nav li.active').index();
@ -315,16 +314,14 @@
$(this).parent('.add-btn').prev('.add-target').children('.start-line').eq(le).children('.input-append').find('.tab-content').each(function() { $(this).parent('.add-btn').prev('.add-target').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'); $(this).children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
}); });
formTip(); formTip();
}); } else if($(this).hasClass('delete_file')) {
$(document).on('click', '.delete_file', function(){
$(this).parents('.input-prepend').remove(); $(this).parents('.input-prepend').remove();
}); } else if($(this).hasClass('remove_existing_record')) {
$(document).on('click', '.remove_existing_record', function(){
if(confirm("<%= I18n.t(:sure?)%>")){ if(confirm("<%= I18n.t(:sure?)%>")){
$(this).children('.should_destroy').attr('value', 1); $(this).children('.should_destroy').attr('value', 1);
$(this).parents('.start-line').hide(); $(this).parents('.start-line').hide();
} }
}); }
}); });
</script> </script>