12
ショッピングカートからアイテムを削除するにはどうすればよいですか?jquery draggable droppable remove dropped
もちろん、アイテムをドラッグアンドドロップすることができます。
$(function() {
$("#catalog").accordion();
$("#catalog li").draggable({
appendTo: "body",
helper: "clone"
});
$("#cart ol").droppable({
activeClass: "ui-state-default",
hoverClass: "ui-state-hover",
accept: ":not(.ui-sortable-helper)",
drop: function(event, ui) {
$(this).find(".placeholder").remove();
$("").text(ui.draggable.text()).appendTo(this);
}
}).sortable({
items: "li:not(.placeholder)",
sort: function() {
// gets added unintentionally by droppable interacting with sortable
// using connectWithSortable fixes this, but doesn't allow you to customize active/hoverClass options
$(this).removeClass("ui-state-default");
}
});
});
... TY ...そんなに!これは、同じ問題を抱えている多くの人々を助けるつもりです! – Spechal
偉大な答えアンドリュー、ありがとう。 –
こんにちはAndrew +1、ドラッグアンドドロップではなく、カート内のアイテムにクローズボタン(近くにあるハイパーリンク)を追加する場合はどうすればよいですか?その場合、 'catalog li.droppable'関数は必要ありません。あなたのコードを使ってそれについてどうやって行くのですか? – aspiring