누군가 제발 나를 도울 수 있는지 궁금합니다.jQuery Image 삭제 확인 메시지
첫 번째로, 저는 JavaScript에 정통하지 않고 어리석은 게시물을 느낄 수도 있기 때문에 진심으로 사과합니다.하지만 도움이 될만한 점이 있으면 큰 도움이 될 것입니다.
갤러리 이미지를 삭제하려면 아래 스크립트를 사용하고 있습니다.
<script type="text/javascript">
Galleria.ready(function() {
this.$('thumblink').click();
$(".galleria-image").append(
"<span class='btn-delete ui-icon ui-icon-trash'></span>");
$(".btn-delete").live("click", function(){
var img = $(this).closest(".galleria-image").find("img");
$.msgbox("You are about to delete this image. It cannot be restored at a later date. Do you wish to continue?", {
type: "alert",
buttons : [
{type: "submit", value: "Delete"},
{type: "cancel", value: "Cancel"}
]
},
function(result) {
if(result)
// send the AJAX request
$.ajax({
url : 'delete.php',
type : 'post',
data : { image : img.attr('src'), idnum: "VALUE", lid: "VALUE"},
success : function(){
img.parent().fadeOut('slow');
}
});
});
return false;
});
});
</script>
나는 지금 내가 지금 시도하고 구현하고 싶은 더 적합 jQuery를 확인 스크립트 here을 발견했습니다. script.js
이 사이트에서 파일을 기존 스크립트를 사용
, 나는 그들을 결합하는 시도하고 함께 온 다음
<script type="text/javascript">
Galleria.ready(function() {
this.$('thumblink').click();
$(".galleria-image").append(
"<span class='btn-delete ui-icon ui-icon-trash'></span>");
$('.btn-delete').click(function(){
var elem = $(this).closest(".galleria-image").find('.item');
$.confirm({
'title' : 'Delete Confirmation',
'message' : 'You are about to delete this item. <br />It cannot be restored at a later time! Continue?',
'buttons' : {
'Yes' : {
'class' : 'blue',
'action': function(){
elem.slideUp();
$.ajax({
url : 'delete.php',
type : 'post',
data : { image : img.attr('src'), idnum: "VALUE", lid: "VALUE"},
success : function(){
img.parent().fadeOut('slow');
}
});
}
},
'No' : {
'class' : 'gray',
'action': function(){} // Nothing to do in this case. You can as well omit the action property.
}
}
}
}
});
});
});
</script>
을 나는 데 문제는 그 페이지가로드 있지만, , 기본 Gallery
이미지 형식으로로드되지 않고 이미지를 삭제하기위한 시각적 트리거로 사용하는 trash icon
이 각 이미지의 맨 아래에 사라졌습니다.
나는 자바 스크립트 콘솔에 들어갔다. 그 내용은 다음과 같다 : Uncaught SyntaxError: Unexpected token }
내 코드에서이 줄을 문제로 강조 표시했다 : $.confirm({
하지만 솔직히 말해서 나는 이것이 무엇을 의미하는지 정말로 모르겠다.
저는 코드를 변경하여 불행히도 성공하지 못하게하려고 많은 변형을 시도해 보았습니다.
나는 누군가가 이걸 좀 들여다보고 내가 잘못 가고있는 부분에 대한 지침을 줄 수 있을지 궁금해했습니다.
많은 감사와 안부
작업 솔루션
<script type="text/javascript">
Galleria.ready(function() {
this.$('thumblink').click();
$(".galleria-image").append(
"<span class='btn-delete ui-icon ui-icon-trash'></span>");
$('.btn-delete').click(function(){
var img = $(this).closest(".galleria-image").find('img');
$.confirm({
'title' : 'Delete Confirmation',
'message' : 'You are about to delete this item. <br />It cannot be restored at a later time! Continue?',
'buttons' : {
'Yes' : {
'class' : 'blue',
'action': function(){
//elem.slideUp();
$.ajax({
url : 'delete.php',
type : 'post',
data : { image : img.attr('src'), idnum: "VALUE", lid: "VALUE"},
success : function(){
img.parent().fadeOut('slow');
}
});
}
},
'No' : {
'class' : 'gray',
'action': function(){} // Nothing to do in this case. You can as well omit the action property.
}
}
});
});
});
</script>
작업중인 페이지에 대한 링크를 제공하거나 jsFiddle.net에 테스트 사례를 추가 할 수 있으면 언제든지 가능합니까? –
안녕하세요, @kennis, 내 게시물에 회신하는 시간을내어 주셔서 감사합니다. 원래 게시물에 테스트 페이지 링크를 추가했습니다. 감사합니다 – IRHM