如何使用fullcalendar.io作为type =" date"选择器? [英] How can I use fullcalendar.io as a type="date" picker?

查看:156
本文介绍了如何使用fullcalendar.io作为type =" date"选择器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Fullcalendar.io 正迅速成为日历应用程式的首选库。是否可以使用它作为< input type =date> 选择器?像 jQuery UIDatepicker一样?

Fullcalendar.io is quickly becoming the top-choice library for calendar applications. Is it possible to use it as a <input type="date"> picker? Something like the jQuery UI "Datepicker"?

我想有一些像... ...

I'd like to have something like...

<form>
<input type="date">
</form>

<script type="text/javascript">
$('input[type=date]').fullCalendar()
</script>


推荐答案

我能够得到像我想要的东西

I was able to get something like I wanted with the following,

$(document).ready(function() {

    $('#foo').click( function () {
        var $input = $(this);
        alert('bar');
        console.log({sibs: $input.siblings().length });
        if ( $input.siblings('.minical').length == 0 ) {

        var $cal = $("<div>", {class:"minical"});
        $input.parent().append($cal);
        $cal.fullCalendar({
          theme: true,
          aspectRatio:1,

          dayRender: function ( date, cell ) {
              $(cell).parent().parent().addClass('hello');
          },

          header: {
              left: 'prevYear,prev,today',
              center: 'title',
              right: 'next,nextYear'            
          },
          dayClick: function ( date, jsEvent, view ) {
              $input.val( date.format() );
              $cal.remove();
          },
          contentHeight: 'auto',
          defaultView: 'month',
          editable: false,
        });
        }
    });

});

和,css

.minical {
    width:200px;
    border: 1px solid black;
    font-size:8px;
}
.minical .fc-row {
    min-height:20px !important;
    height:10px;
    margin:0;
    padding:0 !important;
}
.minical h2 {
    font-size: .8em;
    text-align: center; 
}
.minical button { padding: 0; margin:0; }
.minical .fc-past { color:lightgray }
.minical .fc-day-number { font-size: .8em }
.minical .fc-day-header { font-size: .9em }

查找

Find an example here

这篇关于如何使用fullcalendar.io作为type =&quot; date&quot;选择器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆