在整个日历中显示选择事件到弹出窗口

时间:2019-02-08 04:26:09

标签: javascript fullcalendar

我正在尝试使用完整的日历来选择一个日期,并在弹出框中使用该数据,以便某人可以验证日期/时间并更改文本行

以下代码中的

Nb警报(开始);显示正确选择的日期和时间 例如:Sat Feb 02 2019 00:00:00 GMT + 0000

但是,当尝试将其放入可编辑的文本框中时,“开始”中的数据不会作为变量发送到该行中

'<input class="form-control" type="text" value="start" id="start" >'+

完整代码:

initFullCalendar: function(){

    $calendar = $('#fullCalendar');

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

    $calendar.fullCalendar({
        select: function(start, end) {

        alert(start);

            // on select we show the Sweet Alert modal with an input
            swal({

                title: 'Create x Event',
                html: '<div class="form-group">' +
                        '<input class="form-control" placeholder="Facility" id="facility">' +
                    '</div>'+
                '<div class="form-group">' +
                        '<input class="form-control" placeholder="Provider" id="provider">' +
                    '</div>' +
                '<div class="form-group">' +
                        '<input class="form-control" placeholder="Complaint" id="starttime">' +
                    '</div>'+
                '<div class="form-group">' +
                   '<label for="Category">Select </label>' +
                   '<select class="form-control" id="category">' +
                   '<option>New Patient</option>' +
                   '<option>Review</option>' +
                   '<option>Referral</option>' +
                   '<option>Urgent Request</option>' +
                   '</select>' +
                '</div>' +
                '<div class="form-group">' +
    '<input class="form-control" type="text" value=start id="start" >'+

                   '</div>',

                showCancelButton: true,

1 个答案:

答案 0 :(得分:0)

您需要使用实际的“开始” 变量来设置该元素的value属性,方法是将该元素与字符串的其余部分串联(连接)。现在,您仅包含一个名为“ start”的静态字符串。例如

"February"

请注意,字符串结束,使用'<input class="form-control" type="text" id="start" value="' + start.format() + '"/>' 符号连接起始值,然后字符串重新启动。

您可以根据需要调整日期格式-选中documentation