1

我在一个拖放项目中,我使用gridster。而且我需要在确认后才采取行动,但这不是很聪明。我使用了点击事件,但事件的想法会很有用。这是我的 JS 代码。非常感谢您的帮助

<script type="text/javascript">
var gridster;

$(function(){

gridster = $(".gridster > ul").gridster({
    widget_margins: [5, 5],
    widget_base_dimensions: [240, 95],
    max_cols: 4,
    resize: {
        enabled: false
    },
}).data('gridster');
    $('.gridster ul li').click(function () {
      var id = this.id;
      var class_Name = this.className;
      var col = $(this).attr('data-col');
    if (confirm("Confirmer le changement de status?")) {
      if (class_Name == 'gs-w player-revert') {
        switch (col) {
          case '1' :
            $.ajax ({
              url: "lib/update_func.php",
              type: "POST",
              data: {"arg1": "\""+id+"\"","arg2": "0"}
            });
            break;
          case '2' :
            $.ajax ({
              url: "lib/update_func.php",
              type: "POST",
              data: {"arg1": "\""+id+"\"","arg2": "1"}
            });
            break;
          case '3' :
            $.ajax ({
              url: "lib/update_func.php",
              type: "POST",
              data: {"arg1": "\""+id+"\"","arg2": "2"}
            });
            break;
          case '4' :
            $.ajax ({
              url: "lib/update_func.php",
              type: "POST",
              data: {"arg1": "\""+id+"\"","arg2": "3"}
            });
            break;
          default:
            //
            break;
        }
      }
    } else {
      // unregistered move
    }

    })
 });
 </script>
4

0 回答 0