1

誰かが私を助けてくれるのではないかと思います。

最初に、私は 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 確認スクリプトを見つけました。これを試して実装したいと思います。

このサイトの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>
4

1 に答える 1

0

中かっこがいくつかありません。問題を解決することはできませんが、最初にこのコードを確認してください。必要な中かっこを使用してフォーマットし、結果をお知らせください。

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.
                 }
               }
            });
        });
    });

また、あなたの成功呼び出し関数にはdataパラメータがありません

于 2012-07-14T15:15:34.597 に答える