0

我又来了。我正在使用FullCalendar,我使用属性“事件”来获取议程的值并显示给用户。

想知道在触发此事件之前是否有某种形式,让 FullCalendar 禁用直到返回 Ajax 请求?

这是代码:

$('#calendar').fullCalendar({
    header: {
        left: 'prev,next today',
        center: 'title',
        right: 'agendaWeek,agendaDay'
    },
    defaultView: 'agendaDay',
    editable: true,
    allDaySlot: false,
    selectable: true,
    slotMinutes: 10,
    firstHour: 7,
    minTime: '7:00am',
    slotEventOverlap: false,
    events: '/Agenda/GetDiaryEvents/',
    eventClick: function (calEvent, jsEvent, view) {
        alert('You clicked on event id: ' + calEvent.id
            + "\nSpecial ID: " + calEvent.someKey
            + "\nAnd the title is: " + calEvent.title
            + "\nMédico: " + calEvent.Medico);
    }
});

tks

4

2 回答 2

0

我找到的解决方案就是这个并在下面开发。在调用Ajax的事件之前,先创建一个没有任何按钮的Dialog JQuery,一切OK后自动关闭。

如果它显示另一条错误消息,我想实现,但确实很容易做到......

<script>

    $(document).ready(function () {
        $("#loading").dialog({
            modal: true,
            autoOpen: false,
            closeOnEscape: false            
        });



        var date = new Date();
        var d = date.getDate();
        var m = date.getMonth();
        var y = date.getFullYear();

        $('#calendar').fullCalendar({
            header: {
                left: 'prev,next today',
                center: 'title',
                right: 'agendaWeek,agendaDay'
            },
            defaultView: 'agendaDay',
            editable: true,
            allDaySlot: false,
            selectable: true,
            slotMinutes: 30,
            firstHour: 7,
            minTime: '7:00am',
            slotEventOverlap: false,
            /*events: '/Agenda/GetDiaryEvents/',*/
            events: {
                    url: '/Agenda/GetDiaryEvents/',
                    type: 'GET',
                    data: {
                        custom_param1: 'something',
                        custom_param2: 'somethingelse'
                    },
                    beforeSend: function() {                        
                         $("#loading").parent().children().children('.ui-dialog-titlebar-close').hide();
                         $("#loading").dialog('open');
                    },
                    success: function () {

                    },
                    error: function() {
                        alert('there was an error while fetching events!');
                    },
                    complete: function () {                        
                       $("#loading").dialog('close');
                    },
                },
            eventClick: function (calEvent, jsEvent, view) {
                alert('You clicked on event id: ' + calEvent.id
                    + "\nSpecial ID: " + calEvent.someKey
                    + "\nAnd the title is: " + calEvent.title
                    + "\nMédico: " + calEvent.Medico);
            }
        });

        $('#datepicker').datepicker({
            inline: true,
            onSelect: function (dateText, inst) {
                var d = new Date(dateText.substr(3, 2) + "/" + dateText.substr(0, 2) + "/" + dateText.substr(6, 4));
                $('#calendar').fullCalendar('gotoDate', d);
            },
            dateFormat: 'dd/mm/yy',
            dayNames: ['Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sábado'],
            dayNamesMin: ['D', 'S', 'T', 'Q', 'Q', 'S', 'S', 'D'],
            dayNamesShort: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb', 'Dom'],
            monthNames: ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'],
            monthNamesShort: ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'],
            nextText: 'Próximo',
            prevText: 'Anterior'
        });

        $('.fc-button-prev').click(function () {
            alert('prev is clicked, do something');
            var view = $('#calendar').fullCalendar('getView');
            alert("The view's title is " + view.title);
            alert("start: " + view.start);
            alert("start: " + view.end);

        });

        $('.fc-button-next').click(function () {
            alert('nextis clicked, do something');
        });



    });

</script>
<div class="linha">
    <div id="datepicker"></div>
</div>

<div class="linha">
    <div id='calendar'></div>
</div>
<br />
<br />
<br />
<br />


<div id="loading" title="Processando...">
  <p>Aguarde buscando dados...</p><br /><br />
  <img src="@Url.Content("~/Content/images/icon_48x48_ajax.png")" title="Carregando" />
  <br /><br />
</div>
于 2013-09-14T13:48:46.697 回答
0

我认为没有一种方法可以完全禁用日历。但是,如果您只是想限制任何用户与日历的交互,您可以在 ajax 调用之前将editabledroppableselectable属性设置为 false,然后在成功/完成 ajax 回调中将它们切换回。这应该可以防止用户在此期间操作日历上的任何内容....

于 2013-09-12T20:56:26.737 回答