[英]Fullcalendar with events to Select2
having many events to manage, I opted for a select to dissect the events and drop them in the calendar, I made this <https://jsfiddle.net/max1974/mr5yxe7o/4/>
but I am faced with 2 problems..... 1 ° Initially the objects in the select drop into the calendar, but then if you select other items from the select the drop stops working.有很多事件要管理,我选择了 select 来剖析事件并将它们放入日历中,我做了这个
<https://jsfiddle.net/max1974/mr5yxe7o/4/>
但我面临两个问题.. ... 1° 最初 select 中的对象会落入日历,但随后如果您 select 中的其他项目来自 select,则该拖放将停止工作。 2 ° while I drop the object from the mouse disappears and reappears only when I release it. 2° 当我从鼠标上放下 object 时,它会消失,只有当我松开它时才会重新出现。 Could you help me please.
请问你能帮帮我吗。
Please see my complete working jsfiddle: https://jsfiddle.net/gq8eofyL/请查看我完整的工作 jsfiddle: https://jsfiddle.net/gq8eofyL/
You have to use helper() function to clone the element object inside select2 and avoid relative position hiding the element outside the select2 main <span>
.您必须使用 helper() function 在 select2 中克隆元素 object 并避免相对 position 将元素隐藏在 select2 主
<span>
之外。 Like in this example:就像在这个例子中一样:
helper: function(){
return '<li class="select2-selection__choice ui-draggable ui-draggable-handle">'+$(this).attr('title')+'</li>';
}});
In addition, use Select2 events: https://select2.org/programmatic-control/events in order to re-initialize draggables when Select2 recreates the elements, everytime you select/remove the elements (see my comment1 above):此外,使用 Select2 事件: https://select2.org/programmatic-control/events以便在 Select2 重新创建元素时重新初始化可拖动对象,每次选择/删除元素时(请参阅我上面的评论 1):
function initSelectDraggable(){
$("ul.select2-selection__rendered li").each(function(){
$(this).data('event', {
title: $.trim($(this).text()),
stick: true
});
$(this).draggable({
revert: true,
revertDuration: 0,
helper: function()
{
return '<li class="select2-selection__choice ui-draggable ui-draggable-handle">'+$(this).attr('title')+'</li>';
}
});
});
}
Thanks it works great, now the problem remains that when I drop the event I lose data-id, data-num that I would need to save them in the DB and the event remains blue in the calendar instead of the chosen color.谢谢它很好用,现在问题仍然存在,当我删除事件时,我丢失了我需要将它们保存在数据库中的数据 ID 和数据编号,并且事件在日历中保持蓝色而不是所选颜色。 Thanks again to everyone jsfiddle.net/max1974/bmqdax0f/57/
再次感谢大家 jsfiddle.net/max1974/bmqdax0f/57/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.