我可以使用鼠标来实现这一点。我无法使用键盘让它工作。
这可以使用鼠标删除时添加消息:
$('.drop_01').droppable ({
drop: function() {
$('span.movedItem1').remove();
$(this).prepend('<span class=\"movedItem1\">Item moved to Program philisophy drop area Vision/mission.</span>');
}
});
使用键盘组合Alt + 1时我需要同样的事情。我有这个并尝试了几种变化,但无法让它工作。该项目仍然移动到删除位置,但不显示该消息。
$(".activity").on("keydown", "#activity_contents a", function (e) {
if(e.altKey && ( e.which === 49 )) {
$('.drop_01').droppable ({
drop: function() {
$('span.movedItem1').remove();
$(this).prepend('<span class=\"movedItem1\">Item moved to Program philisophy drop area Vision/mission.</span>');
}
});
}
});
如果这是可以实现的,请有人帮忙。澄清这只是为了显示消息,拖放功能是很多未发布的附加代码。
答案 0 :(得分:0)
我看错了方法。我有的解决方案(虽然有点不整洁)是:
// CtRL key moves something to next column
$(".activity").on("keydown", ".connected-sortable.draggable li", function (event) {
var $this = $(this)
, key = event.keyCode || e.which
, $holder = $this.parents(".activity")
, $selectedul = $this.parent()
, $availableuls = $holder.find(".connected-sortable")
, currentlistindex = $selectedul.data("list-index")
, nextlistindex = currentlistindex + 1
, $nextul = $holder.find(".connected-sortable[data-list-index='" + nextlistindex + "']")
, $originalul = $holder.find(".connected-sortable[data-list-index='0']");
if ($nextul.length == 0) {
$nextul = $originalul;
}
if(nextlistindex === 1) {
$('span.movedItema').remove();
$('span.movedItemb').remove();
$('span.movedItemc').remove();
$('span.movedItemd').remove();
$(this).focus().prepend('<span class=\"movedItema offscreenText\">Item moved to Program philisophy drop area Vision/mission.</span>');
}
if(nextlistindex === 2) {
$('span.movedItema').remove();
$('span.movedItemb').remove();
$('span.movedItemc').remove();
$('span.movedItemd').remove();
$(this).focus().prepend('<span class=\"movedItemb offscreenText\">Item moved to Program philisophy drop area Beliefs/values.</span>');
}
if(nextlistindex === 3) {
$('span.movedItema').remove();
$('span.movedItemb').remove();
$('span.movedItemc').remove();
$('span.movedItemd').remove();
$(this).focus().prepend('<span class=\"movedItemc offscreenText\">Item moved to Program philisophy drop area Strategies.</span>');
}
if(nextlistindex === 4) {
$('span.movedItema').remove();
$('span.movedItemb').remove();
$('span.movedItemc').remove();
$('span.movedItemd').remove();
$(this).focus().prepend('<span class=\"movedItemd offscreenText\">Item moved back to Program philisophy Factors list.</span>');
}