如何在fullcalendar jquery插件中获取allDay的值?

时间:2015-02-28 07:04:44

标签: javascript php jquery fullcalendar

我正在使用fullcalendar jquery插件,我希望得到allDay的值为true或false,并且我想将值附加到form.But得到的值是[object Object] < / p>

<input type="hidden" id="apptAllDay" value="[object Object]">


<script type="text/javascript">
$(document).ready(function(){

    $('#calendar').fullCalendar({
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay'
        },
        defaultDate: '2015-02-12',
        selectable: true,
        selectHelper: true,
        select: function(start, end, allDay) {

            $('#apptStartTime').val(start);
            $('#apptEndTime').val(end);          
            $('#apptAllDay').val(allDay);


            $.magnificPopup.open({
                  items: {
                    src: '#popup',
                    type: 'inline'
                  }
            });


        },
        editable: true,
        eventLimit: true, // allow "more" link when too many events
        eventStartEditable : false,
        events: "http://localhost/app1/events",
    });



    $(document).on("click","#addEvent",function(e) {
        e.preventDefault();
        doSubmit();
    });


    function doSubmit(){

        var title = $("#titleContainer").val();
        var description = $.trim($("#descContainer").val());
        var url = $("#urlContainer").val();

        if (!title) {
            alert("Title is required");
            return false;
        }

        $("#calendar").fullCalendar('renderEvent',
            {
                title: title,
                start: new Date($('#apptStartTime').val()),
                end: new Date($('#apptEndTime').val()),
                allDay: ($('#apptAllDay').val() == "true")
            },
        true);

       }

});

如何获得TRUE或FAlSE的实际值?

1 个答案:

答案 0 :(得分:0)

这可能对您有所帮助,可根据您的要求进行更改。

&#13;
&#13;
function parseClientEvents(){
    var clientArr = $('#calendar').fullCalendar('clientEvents');
    for(i in clientArr){
         console.log(clientArr[i]);//gives events full description.
         console.log(clientArr[i].allDay);
        //check for value here and append to your hidden field.
       //all your logic goes here.         
    }
    return true;
}
&#13;
&#13;
&#13;