내 HTML 코드는 삭제 페이지로 이동, 대신에이 경고의 jquery에서 다시 기본 설정을 사용하지 않도록 설정하는 방법은 무엇입니까?
<a title="Delete" onclick="if (confirm('Delete selected item?')){ return true; }else{ event.stopPropagation(); event.preventDefault();};" class="delete" href="link to delete page">
</a>
, 나는 특정 조건에 해당 사용자에 본사를 둔 내 경고 기능을 제공 원하는 옵션을 확인한다. 내 jQuery 코드는
,
$('.delete').removeAttr('onclick').click(function(e) {
e.preventDefault();
var url = $(this).attr("href");
var a = url.split('id_product=');
var next = a[1];
var id=next.split('&');
var base_url = $("#ajaxbase").val();
$.ajax({
type : "POST",
url : base_url+"modules/sample/ajax/sample.php",
data: {id:id[0]}
}).done(function(response) {
var res=$.trim(response);
if (res == '1') {
if (confirm('This Product is configured in chain.Deleting this product will affect your chain.Are you sure to do this?')) {
return true;
} else {
return false;
}
} else if (res == '2') {
if (confirm('Are you sure to delete this product?')) {
return true;
} else {
return false;
}
}
});
내 확인 메시지가 표시되지만 사용자가이를 확인하면, 그것은 삭제 페이지로 이동하지 않았다. 누구든지 나를 도울 수 있습니까?
무엇을 찾고있을 수 있습니다, 나는 버튼의 동작을 모방하는 태그를 사용, 당신은 완벽하게 제어 할 것 ! – MackieeE