$(document).ready(function(){ $(".table_id").each(function(){ var rows = $(".table_id:contains('"+$(this).text()+"')"); if(rows.length > 1){ rows.eq(0).attr("rowspan", rows.length); rows.not(":eq(0)").remove(); } }) }); $(document).on('click', '#addEquip', function (){ $.ajax({ url: '/equip/equipEditModal', type: 'GET', dataType:"html", success: function(html){ $("#equipEditModalContent").empty().append(html) $("#equipEditModal").modal('show') }, error:function(){ } }); }) $(document).on('change', '#equType', function (){ const equType = $(this).val(); $.ajax({ url: '/equip/equipTypeSelecBox', data: { equType, }, type: 'GET', dataType:"html", success: function(html){ console.log(html); $("#detailType").empty().append(html) }, error:function(){ } }); }); $(document).on('click', '#saveEquip', function (){ if(confirm("저장하시겠습니까?")){ let ajaxUrl = "/equip/saveEquip"; const formData = new FormData($("#equipEditForm")[0]); contentFade("in"); $.ajax({ type : 'POST', data : formData, url : ajaxUrl, processData: false, contentType: false, success : function() { alert("저장되었습니다."); location.reload(); contentFade("out"); }, error : function(xhr, status) { alert("저장에 실패하였습니다.") contentFade("out"); } }) } }); $(document).on('click', '#equUpdateBtn', function (){ if($('input:checkbox[name=equChk]:checked').length > 1){ alert("한개만 선택해주세요") return false; } const target = $('input:checkbox[name=equChk]:checked'); const equKey = Number(target.parents('tr').find('.equKey').val()); showUpdateModal(equKey); }) function showUpdateModal(equKey){ $.ajax({ url: '/equip/updatePage', data: {equKey: equKey}, type: 'GET', dataType:"html", success: function(html){ $("#configEqu").empty().append(html) $("#equipModifyModal").modal('show'); }, error:function(){ } }); } $(document).on('click', '#addImgBtn', function (){ $("#imgUpload").remove(); $("#imgUpdate").show(); }) function deleteImg(equKey,versionNo){ $('#equipModifyForm').append('', ''); $("#imgUpload").remove(); $("#imgUpdate").show(); } $(document).on('click', '#updateEquip', function (){ if(confirm("수정하시겠습니까?")){ let ajaxUrl = "/equip/updateEquip"; const formData = new FormData($("#equipModifyForm")[0]); contentFade("in"); $.ajax({ type : 'POST', data : formData, url : ajaxUrl, processData: false, contentType: false, success : function(data) { alert("수정되었습니다."); showUpdateModal(data); contentFade("out"); }, error : function(xhr, status) { alert("수정에 실패하였습니다.") contentFade("out"); } }) } });