2017-04-30 2 views
2

Sweet Alert 라이브러리를 사용하여 경고를 보내려고합니다. 항목 삭제에 대한 확인 알림을 만들기 위해 코드를 통합하려고했지만 항목을 삭제하기위한 버튼을 클릭하면 이러한 항목이 작동하지 않습니다. 대화 상자가 표시되지 않습니다.감미로운 경고 대화 상자를 표시하는 중 오류가 발생했습니다.

코드 달콤한 경고를 통합 전에 :

$(".delete-link").click(function() { 
    var id = $(this).attr("id"); 
    var del_id = id; 
    var parent = $(this).parent("td").parent("tr"); 
    if (confirm('Sure to Delete ID no = ' + del_id)) { 
     $.post('delete.php', { 'del_id': del_id }, function(data) { 
      parent.fadeOut('slow'); 
     }); 
    } 
    return false; 
}); 

코드 달콤한 경고를 통합 후 :

$(".delete-link").click(function() { 
     var id = $(this).attr("id"); 
     var del_id = id; 
     var parent = $(this).parent("td").parent("tr"); 
    }); 

    swal({ 
      title: "Are you sure you want to delete?", 
      text: "Sure to Delete ID no = " + del_id, 
      type: "warning", 
      showCancelButton: true, 
      confirmButtonColor: "#DD6B55", 
      confirmButtonText: "Yes", 
      closeOnConfirm: false 
     }, 
     function() { 
      $.post('delete.php', { 'del_id': del_id }, function(data) { 
       parent.fadeOut('slow'); 
      }); 
     }); 
    return false; 

}); 
+0

콘솔에서 오류가 발생하고 있습니까? –

+0

아니 내가 thibk 코드에 문제가 있지만 지금은 어디 – marte

답변

0

내가 코드에 구문 오류가 있다고 생각. 이것을 시도해보고 작동하는지 확인하십시오. [내 코드는 테스트하지 않았습니다]. 작동하지 않으면 알려주세요.

$(".delete-link").click(function() { 
var id = $(this).attr("id"); 
var del_id = id; 
var parent = $(this).parent("td").parent("tr"); 

swal({ 
    title: "Are you sure you want to delete?", 
    text: "Sure to Delete ID no = " + del_id, 
    type: "warning", 
    showCancelButton: true, 
    confirmButtonColor: "#DD6B55", 
    confirmButtonText: "Yes", 
    cancelButtonText: "No", 
    closeOnConfirm: true, 
    closeOnCancel: true 
}, function(isConfirm) { 
    $.post('delete.php', {'del_id':del_id}, function(data) { 
     parent.fadeOut('slow'); 
    }); 
}); 
return false; 
}); 
+0

완벽하게 작동합니다, 감사합니다 :) – marte