0

我想把扑克牌拿在手上,但要让它们可以放在新的空间里。手中的卡片也应该是可重新排序的(可排序的)。

[   #new_space                          ]

[   #hand  [.card] [.card] [.card]      ]

这是我为 JS 尝试过的:

$("#hand").sortable({
  distance: 15,
  opacity: 0.75,
  placeholder: "card medium invisible"
})

$("#hand .card").draggable({
  distance: 15,
  revent:"invalid",
  opacity: 0.75,
  placeholder: "card medium invisible"
})

$("#new_space").droppable(
  hoverClass: 'ui-state-highlight',
  drop: function(event, ui) {
    var $card = $(event.originalEvent.target)
    $("#new_space").append($card)
    $card.css({
      "top": "",
      "left": "",
      "right": "",
      "bottom": ""
    })
  })    

但它并没有真正起作用......如果它们没有被丢弃,它们不会恢复到它们的旧空间,如果它们被丢弃,它们也不会被正确地附加到新空间中。(虽然如果它们被丢弃,它们会发生一些事情,但目前还不清楚是什么。)

如何使它起作用?

4

1 回答 1

0

$("#hand .card").draggable({ appendTo: "body", cursor: "move", helper: 'clone', revert: "invalid" });

$("#new_space").droppable({
    tolerance: "intersect",
    accept: "#hand .card",
    hoverClass: "ui-state-hover",
    drop: (function (event, ui) {
 $(this).append($(ui.draggable));
$card.css({
  "top": "",
  "left": "",
  "right": "",
  "bottom": ""
})
于 2014-02-27T06:20:45.447 回答