.hide()/.show() 和 Droppable
我有一个问题,当可拖动触发拖动时,元素调用 .show() ,但不允许我放入可放置中。我该如何解决这个问题?
$(document).ready(function() {
$(".folder").droppable({
greedy: true,
drop: function(event, ui) {
$(".folder").hide();
},
tolerance: 'touch'
});
$(".folder").hide();
$(".draggable_folder").draggable({
cursor: 'move',
cursorAt: { top: 8, left: 0 },
drag: function(event, ui) {
$(".folder").show();
},
helper: function(event) {
var subject = $(this).find('.message_subject').html();
return $('<div class="ui-widget-header" style="max-width: 100px;">'+subject+'</div>');
}
});
});
<ul>
<li class="folder">{$folders[f_list].name}</a><div style="clear:both"></div></li>
</ul>
<table>
<tr class="draggable_folder"><td>test</td></tr>
</table>
I have a problem where the element calls .show() when the draggable triggers drag, does not let me drop into the droppable. How can I fix this?
$(document).ready(function() {
$(".folder").droppable({
greedy: true,
drop: function(event, ui) {
$(".folder").hide();
},
tolerance: 'touch'
});
$(".folder").hide();
$(".draggable_folder").draggable({
cursor: 'move',
cursorAt: { top: 8, left: 0 },
drag: function(event, ui) {
$(".folder").show();
},
helper: function(event) {
var subject = $(this).find('.message_subject').html();
return $('<div class="ui-widget-header" style="max-width: 100px;">'+subject+'</div>');
}
});
});
<ul>
<li class="folder">{$folders[f_list].name}</a><div style="clear:both"></div></li>
</ul>
<table>
<tr class="draggable_folder"><td>test</td></tr>
</table>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在
$(".draggable_folder").draggable
中,将drag: function(event, ui)
更改为start: function()
。这将使.folder
可见并且可放置的将变为活动状态。可拖动的最终代码:In
$(".draggable_folder").draggable
, changedrag: function(event, ui)
tostart: function()
. This will make.folder
visible and the droppable will become active. The final code for draggable: