简体   繁体   English

全日历动态添加不起作用

[英]Full calender add dynamically not working

I tries to add full calendar. 我尝试添加完整的日历。 First time I clicked the button and it added success. 我第一次单击该按钮,它增加了成功。 after I clear my ScheduleCalender div using jquery empty() method. 在我使用jquery empty()方法清除ScheduleCalender div之后。 and I re-run the full calender code. 然后我重新运行完整的日历代码。 But full calender doe's not appear. 但是没有出现完整的压延母鹿。 At lease no content appear inside the div. 至少,div内没有内容。 Here my code. 这是我的代码。 my div selector is working fine. 我的div选择器工作正常。 I tested that. 我测试了

$('#addNewTimeScheduleEntry').click(function () {
    $('#scheduleCalendar').empty();
    var scheduleYear = $('.scheduleYear').val();
    var scheduleMonth = $('.scheduleMonth').val();

    $('#scheduleCalendar').fullCalendar({
        defaultDate: scheduleYear + '-' + scheduleMonth + '-01',
        header: {
            left: '',
            center: '',
            right: 'title'
        },
        eventRender: function (event, element) {
            element.qtip({
                content: event.description,
                style: {
                    classes: 'qtip-dark qtip-shadow'
                },
                position: {
                    my: 'top left', // Position my top left...
                    at: 'bottom right', // at the bottom right of...
                    target: $(element) // my target
                }
            });

        },
        height: $('.panel-body').height()-50

    });

});

here has full calendar link 这里有完整的日历链接

Here my html 这是我的HTML

<div class="panel-body fixed-content">
    <div class="year-month-control">
    <select class="selectpicker scheduleYear">
    </select>

    <select class="selectpicker scheduleMonth">
    </select>

        <button type="button" id="addNewTimeScheduleEntry" class="btn btn-default" id="addnewScheduleEntry"><i class="fa fa-plus"></i>&nbsp;Add Entry</button>
        <button type="button" id="addNewTimeScheduleEntry" class="btn btn-default" id="saveScheduleEntry" ><i class="fa fa-upload"></i>&nbsp;Save Entry</button>
    </div>
    <br/>
    <div id='scheduleCalendar'></div>

</div>

It runs fine even after you empty the div. 即使您清空div,它也可以正常运行。 the only difference is that I have put it in the document ready event but I dont think that should make any difference. 唯一的区别是,我已将其放入文档就绪事件中,但我认为这不会有任何区别。 Here are 2 jsfiddles; 这是2个jsfiddles; http://jsfiddle.net/2qs8tyg1/2/ http://jsfiddle.net/2qs8tyg1/2/

$(document).ready(function() {

    $('#addNewTimeScheduleEntry').click(function () {
        $('#scheduleCalendar').empty();
        $('#scheduleCalendar').fullCalendar({});
        var scheduleYear = date.getFullYear();
        var scheduleMonth = date.getMonth();

        $('#scheduleCalendar').fullCalendar({
            defaultDate: scheduleYear + '-' + scheduleMonth + '-01',
            header: {
                left: '',
                center: '',
                right: 'title'
            },
            eventRender: function (event, element) {
                element.qtip({
                    content: event.description,
                    style: {
                        classes: 'qtip-dark qtip-shadow'
                    },
                    position: {
                        my: 'top left', // Position my top left...
                        at: 'bottom right', // at the bottom right of...
                        target: $(element) // my target
                    }
                });

            },
            height: $('.panel-body').height()-50

        });

    });

});

http://jsfiddle.net/justinobney/uaNgR/ http://jsfiddle.net/justinobney/uaNgR/

jQuery(document).ready(function() {

        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: 'month,agendaWeek,agendaDay'
            },
            viewDisplay: function(view) {
                window.location.hash = "month=" + (view.start.getMonth() + 1) + "&year=" +view.start.getFullYear();
            },
            editable: true,
            events: [
                {
                    title: 'All Day Event',
                    start: new Date(y, m, 1)
                },
                {
                    title: 'Long Event',
                    start: new Date(y, m, d-5),
                    end: new Date(y, m, d-2)
                },
                {
                    id: 999,
                    title: 'Repeating Event',
                    start: new Date(y, m, d-3, 16, 0),
                    allDay: false
                },
                {
                    id: 999,
                    title: 'Repeating Event',
                    start: new Date(y, m, d+4, 16, 0),
                    allDay: false
                },
                {
                    title: 'Meeting',
                    start: new Date(y, m, d, 10, 30),
                    allDay: false
                },
                {
                    title: 'Lunch',
                    start: new Date(y, m, d, 12, 0),
                    end: new Date(y, m, d, 14, 0),
                    allDay: false
                },
                {
                    title: 'Birthday Party',
                    start: new Date(y, m, d+1, 19, 0),
                    end: new Date(y, m, d+1, 22, 30),
                    allDay: false
                },
                {
                    title: 'Click for Google',
                    start: new Date(y, m, 28),
                    end: new Date(y, m, 29),
                    url: 'http://google.com/'
                }
            ]
        });

    function setupRouting() {
        $.jsRouter.mapRoute('Month Change', 'month={month}&year={year}', MonthChanged);
    }

    function MonthChanged(args) {
        var vMonth = args.month;
        var vYear = args.year;
        console.log('event trapped:', args);
    }
        $.getScript('http://www.tasktrackr.com/js/routing.js',setupRouting);
    //jQuery.deparam.fragment()
    //$.getScript('https://raw.github.com/cowboy/jquery-bbq/master/jquery.ba-bbq.min.js')
    });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM