Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/412.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 当我在fullCalendar上选择一个时间段时,如何使模式窗口弹出?_Javascript_Jquery_Html_Twitter Bootstrap_Fullcalendar - Fatal编程技术网

Javascript 当我在fullCalendar上选择一个时间段时,如何使模式窗口弹出?

Javascript 当我在fullCalendar上选择一个时间段时,如何使模式窗口弹出?,javascript,jquery,html,twitter-bootstrap,fullcalendar,Javascript,Jquery,Html,Twitter Bootstrap,Fullcalendar,我已经能够让我的FullCalendar插件在本地主机上工作,并且希望能够通过弹出窗口创建事件。下面的代码设置日历并允许我选择一个时间段,我想显示模式视图以允许输入: $(document).ready(function(){ var calendar = $('#calendar').fullCalendar({ header: { left: 'prev,next today', center: 'title',

我已经能够让我的FullCalendar插件在本地主机上工作,并且希望能够通过弹出窗口创建事件。下面的代码设置日历并允许我选择一个时间段,我想显示模式视图以允许输入:

$(document).ready(function(){
   var calendar = $('#calendar').fullCalendar({
    header: 
       {
         left: 'prev,next today',
         center: 'title',
         right: 'agendaDay agendaWeek month'
       },
    defaultView: 'agendaWeek',
    slotDuration : '00:15:00',
    scrollTime: '13:00:00',
    minTime : '09:00:00',
    maxTime : '21:00:00',
    slotEventOverlap: false,
    firstDay : 1,
    selectable: true,
    selectHelper: true,
    editable:true,
    //select function:
    select: function(start, end, allDay){
        endtime = $.fullCalendar.formatDate(end, 'h:mm tt');
        starttime = $.fullCalendar.formatDate(start, 'ddd, MMM d, h:mm tt');
        var mywhen = starttime + ' - ' + endtime;
        $('#createEventModal #apptStartTime').val(start);
        $('#createEventModal #apptEndTime').val(end);
        $('#createEventModal #apptAllDay').val(allDay);
        $('#createEventModal #when').text(mywhen);
        $('#createEventModal').modal('show');
    },
});
//function to submit the form
 $('#submitButton').on('click', function(e){
    //cancel the link options
    e.preventDefault();

    doSubmit();
   });
});
function doSubmit(){
    alert("form submitted");
    $("#createEventModal").modal('hide');
$("#calendar").fullCalendar('renderEvent',
    {
        title: $('#clientName').val(),
        start: new Date($('#apptStartTime').val()),
        end: new Date($('#apptEndTime').val()),
        allDay: ($('#apptAllDay').val() == "true"),
    },
    true);
}

这是用于创建模式表单的HTML代码:

    <!--call the calendar -->
    <div id='calendar'></div>
    <!-- form to capture appointment Data-->
    <div id="createEventModal" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="myModalLabel1" aria-hidden="true">
        <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
        <h3 id="myModalLabel1">Book Appointment</h3>
        </div>
    <div class="modal-body">
            <form id="createAppointmentForm" class="form-horizontal">
                <div class="control-group">
                <label class="control-label" for="inputClient">Client:</label>
                    <div class="controls">
                    <input type="text" name="clientName" id="clientName" placeholder="name here"
                    tyle="margin: 0 auto;" data-provide="typeahead" data-items="4" data-source="[
                    &quot;Value 1&quot;,&quot;Value 2&quot;,&quot;Value 3&quot;]">
                    <input type="hidden" id="apptStartTime"/>
                    <input type="hidden" id="apptEndTime"/>
                    <input type="hidden" id="apptAllDay"/>
                    </div>
                </div>
            <div class="control-group">
                <label class="control-label" for="when">When:</label>
                    <div class="controls controls-row" id="when" style="margin-top:5px;">
                    </div>
                </div>
            </form>
        </div>
    <div class="modal-footer">
        <button type="button" data-dismiss="modal" aria-hidden="true" class="btn">Cancel</button>
        <button type="submit" id="submitButton" class="btn btn-primary">Save Appointment</button>
        </div>
    </div>
我不知道我缺少了什么来让表单呈现给用户。我是网络开发新手,非常感谢您的帮助。请尝试使用。为了满足您的需要,您可能需要以下代码

$(".modal-body").dialog({
    title: "Book Appointment",
    modal: true,
    buttons: {
        "Save Appointment": function() {
            //appt save code here
        },
        Cancel: function() {
            $(this).dialog("close");
        }
    }
});