控制单击或移动单击多个项目并拖动它们 [英] Control click or shift click multiple items and drag them
问题描述
我已经在列表2中排序了一个拖放情况,感谢CoolEsh在之前的惊人的帮助..
所以现在我需要一个控制点击来选择多个并拖动它。但是我不想加载一些标记和jQuery。但是我也不想像我所说的那样使用一个复杂的插件。
任何想法?
事件 e
内置了可以访问的变量检查是否已经按下控件, alt 或 shift 。看看 here 。
$ b $($ e code $ $''''''''''''''''''' $ b if(e.altKey)alert('altressed');
});
如果你知道控件也被按下,你可以添加一个类 selectedItem
或类似的东西。在mouseup事件中,您可以检查是否按下该键,如果没有,则删除 selectedItem
类。而不只是添加一个可拖动到 $('。selectedItem')
,你几乎在那里。
I have been looking on these forums all day and tried lots of plug-ins namely : jquery.hotkeys.js and the http://thechriswalker.net/select-drag/ example here complete with an excellent plug-in, it's just a lot more complex than what I think I'm looking for.
I already have a drag and drop situation with sortable in list 2 thanks for to CoolEsh for his amazing help earlier on.. connecting sortable lists disallowing sorting on the first list jQuery
So now I'm needing a control click to select more than one and drag it across. But I don't want loads of mark-up and jQuery. but I also don't want to use a complex plug-in like the ones I mentioned.
Any ideas?
The event e
has built in variables that you can access for checking if control, alt or shift have been pressed. Have a look here.
$('#selectableitems p').click(function(e) {
if(e.ctrlKey) alert('control pressed');
if(e.altKey) alert('alt pressed');
});
If you know that control is also pressed, you could add a class selectedItem
or something like that. On a mouseup event you could check if the key is pressed and delete the selectedItem
class if not. Than just add a draggable to the $('.selectedItem')
and you're pretty much there.
这篇关于控制单击或移动单击多个项目并拖动它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!