将所选日期获取到窗体JQuery完整日历



我正在加载一个弹出表单,通过单击每个日期单元格中的+图标,在日历界面中添加约会。我使用下面给出的方法将+图标添加到日期单元格中,当用户点击它时,模式框就会出现。

viewDisplay:function (view) {
            if(i==0){
                $(".fc-day-number").before("<button class="remove-b" style="border:none; background:none" data-toggle="modal" data-target="#myModal"><i class="icon-plus add_appt"></i></button>");
                i++;
            }        
},

当用户单击+图标保存到数据库中时,我想将所选日期加载到表单中的字段中。

有人能帮我知道有什么可能的方法吗?

这就是我解决类似问题的方法。仅供参考,我使用的是完整日历版本1.6.4.

        $(document).ready(function () {

            /* Add mouseover for the day cells so we can keep track of the day the mouse is over.
            * This is so we know which day a mouse click occured on when clicking an icon or div
            * in the day cell.
            */
            $('td.fc-day').mouseover(function () {
                // Get the date.
                var mouseoverDate = $(this).data('date');
                // Add to hidden input field.
                $('#hiddenMouseOverDate').val(mouseoverDate);
                /* Since the mouseover is not fully reliable we will
                * select and highlight the cell for visual representation
                * to the user so they know what date the event will actually 
                * be added to.
                */
                $('#calendar').fullCalendar('unselect');
                $('.fc-cell-overlay').removeClass('fc-cell-overlay');
                $('#calendar').fullCalendar('select', strDate, strDate, true);
                $(this).addClass('fc-cell-overlay');
            });
            /* We do the same thing for fc-day-number. */
            $('td.fc-day-number').mouseover(function () {
                // Get the date.
                var mouseoverDate = $(this).data('date');
                // Add to hidden input field.
                $('#hiddenMouseOverDate').val(mouseoverDate);
                // Select and highlight the cell.
                $('#calendar').fullCalendar('unselect');
                $('.fc-cell-overlay').removeClass('fc-cell-overlay');
                $('#calendar').fullCalendar('select', strDate, strDate, true);
                $("td.fc-day").filter("[data-date='" + strDate + "']").addClass('fc-cell-overlay');
            });
            /* Then in your plus icon click event you would need to store the date you saved 
             * in the '#hiddenMouseOverDate' field and copy it to some other field you want.
             * (This is to prevent using an incorrect date due to the user moving his/her mouse
             * into another day cell after they clicked on the plus icon)
             */
            $('.icon-plus').click(function (e) {

                var useDate = $('#hiddenMouseOverDate').val();
                // Rest of you code here...
                // .....
            });
        });

我做了一些调整来适应你的问题,所以我还没有测试它,但逻辑是存在的。

相关内容

  • 没有找到相关文章

最新更新