我想知道是否有人能夠幫助我。jQuery圖像刪除確認信息
首先,我誠摯的道歉,因爲我不是很熟悉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
已消失在每個圖像的底部。
我已經去到JavaScript控制檯,它顯示的錯誤是: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上? – 2012-07-14 15:01:09
嗨@kennis,感謝您花時間回覆我的帖子。我在原始文章中添加了一個鏈接到測試頁面。親切的問候 – IRHM 2012-07-14 15:15:37