在渲染中合并新日历的两个变量

Merge two variables of new calendars in the render

提问人:Anonimo 提问时间:7/11/2023 最后编辑:ADysonAnonimo 更新时间:7/18/2023 访问量:50

问:

这个问题可能有点奇怪,但它将是我在这个问题中遇到的问题的解决方案。

是否可以在 render() 中连接两个变量。我将解释:

$(".btn-show").click(function(e) {
  e.preventDefault();
  el = $(this).data('element');
  $(el).show();
  $("section > div").not(el).hide();
});

$(document).on('click', '.dad-visita', function(){
    if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
          initialViews = 'timeGridWeek';
     }else{
          initialViews = 'timeGridWeek';
     }  

     var calendarEl = document.getElementById('calendario');
     var today = moment().day();

     var calendar = new FullCalendar.Calendar(calendarEl, {
        
        headerToolbar: {
            left: 'prev,next today',
            center: 'title',
            right: 'dayGridMonth,timeGridWeek,timeGridDay'
        },
        locale: "pt-br",

        buttonText:{
            today:    'Hoje',
            list:     'Lista'
        },

        navLinks: true,             
        firstDay: today,
        hiddenDays: [ 0 ],
        initialView: initialViews,
        editable: true,
        selectable: true, 
        unselectAuto:true,
        eventOverlap: false,
        eventColor: '#f16621', 
        slotDuration: '00:45',
        allDaySlot : false,
        eventStartEditable: false,
        eventDurationEditable:false,
        longPressDelay: 0,
        nowIndicator: "true",
        slotMinTime: '10:30',
        slotMaxTime: '12:00',
        contentHeight: 'auto',
        
                

    });
    
    var calendarr = new FullCalendar.Calendar(calendarEl, {
        
        headerToolbar: {
            left: 'prev,next today',
            center: 'title',
            right: 'dayGridMonth,timeGridWeek,timeGridDay'
        },
        locale: "pt-br",

        buttonText:{
            today:    'Hoje',
            list:     'Lista'
        },

        navLinks: true,             
        firstDay: today,
        hiddenDays: [ 0 ],
        initialView: initialViews,
        editable: true,
        selectable: true, 
        unselectAuto:true,
        eventOverlap: false,
        eventColor: '#f16621', 
        slotDuration: '00:45',
        allDaySlot : false,
        eventStartEditable: false,
        eventDurationEditable:false,
        longPressDelay: 0,
        nowIndicator: "true",
        slotMinTime: '14:30',
        slotMaxTime: '19:00',
        contentHeight: 'auto',

    });

    calendar.render();
    calendarr.render();
});
<link href="https://cdn.jsdelivr.net/npm/[email protected]/main.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/main.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/locale/pt-br.js"></script>

<a href="s160" data-element="#minhaDiv160" class="btn-show dad-visita">
    <i class="metismenu-icon pe-7s-info"></i>
    Consultar Visitas
</a>

<section id="s160">
  <div style="display:none;" id="minhaDiv160">
    <div class="cal-wrapper"><div id='calendario'></div></div>
    <div class="cal-wrapper"><div id='calendario1'></div></div>
  </div>
</section>

在我放置的示例中,我有代码来生成两个日历,一个用于 10:30 到 12:00,另一个用于 14:30 到 19:00。最后我必须一次渲染一个,它只显示第二个日历。是否可以同时渲染两者,以便它们都在同一日历中?我试过这样:

calendar.calendarr.render();

但这不会生成任何日历

JavaScript 完整日历 -5

评论

0赞 ADyson 7/18/2023
Is it possible to render both at once, so that they are both within the same calendar...你的意思是在同一个HTML元素中?不,这完全没有意义。正如你所发现的,一个只会覆盖另一个。在你之前的问题中,我已经给了你一个可能的解决方案,以解决你原来的问题......你试过了吗?
0赞 Anonimo 7/19/2023
@ADyson 我已经尝试过并尝试搜索,但我无法实现您的建议。你能举个例子让我理解吗?
0赞 ADyson 7/19/2023
回到原来的问题并编辑它以显示你到目前为止尝试过的内容,然后我可能会帮助你解决它。它应该只是获取两个日期之间的差异,并检查它是否等于 45 分钟。
0赞 Anonimo 7/19/2023
@ADyson 好的,我会在另一个问题中添加代码,看看我做了什么

答: 暂无答案