用于fullCalendar js的DOM操作 [英] DOM manipulation for fullCalendar js

查看:171
本文介绍了用于fullCalendar js的DOM操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用

解决方案

你可以在纯css中使用

演示: http:// jsfiddle。 net / IrvinDominin / dcx5unzd / 1 /

I'm using fullcalendar, a JavaScript event calendar which leverages on jQuery.

I need to edit all day cells of the calendar, adding two verticals lists, both floating left; do I have to achieve that handling events?

Well; I think not.

Is there a simple and effective way to achieve that?

Below is my code illustrating my failed attempt to achieving that:

$("#calendar").fullCalendar({   
    header: {
        left: 'prev',
        center: 'title',
        right: 'next'
    },
    //defaultDate: '2015-02-12',
    monthNames:
        ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
    dayNamesShort:
        ['D', 'L', 'M', 'M','J', 'V', 'S'],     
    editable: false,
    eventLimit: true, // allow "more" link when too many events
    eventRender: function(event, element) {
        //element.find(".fc-view-month td").after($("<td class=\"fc-day\"></td>").html("Prueba"));
        //element.find("div.fc-event-inner").prepend("<img src='" + event.imageurl +"' width='12' height='12'>");
        //element.find("div.fc-event-inner").prepend("<img src='../img/ico_calen_min_1.png' width='12' height='12' />");
        //element.find("table tbody td").prepend("<img src='../img/ico_calen_min_1.png' width='12' height='12' />");
        //element.find(".fc-title").after($("<span class=\"fc-event-icons\"></span>").html("<ul><li><img src=\"../img/ico_calen_min_1.png\" /></li><li><img src=\"../img/ico_calen_min_1.png\" /></li></ul>"));             
        //element.find(".fc-view-month").after($("td").html("<ul><li><img src=\"../img/ico_calen_min_1.png\" /></li><li><img src=\"../img/ico_calen_min_1.png\" /></li></ul>"));                
        //$("#calendar .fc-view-month td").append("<input type=\"checkbox\">AM<br>");
    }
});

解决方案

You can do it in pure css using ::before pseudo and content and for example an iconic font like fontawesome.

The content CSS property is used with the ::before and ::after pseudo-elements to generate content in an element. Objects inserted using the content property are anonymous replaced elements.

Following an example on the month view.

\A and white-space: pre are needed for line breaking the icons.

Code:

.fc-widget-content::before {
    margin-top: 20px;
    font-family:'FontAwesome';
    content:"\f0c9\A\f0ac\A\f09c\A\f257";
    position: absolute;
    white-space: pre;
}

Demo: http://jsfiddle.net/IrvinDominin/dcx5unzd/

UPDATE

To display a column with the numbers you can use the event and style it accordingly like:

.fc-event{
    margin-left: 20px;
    width: auto !important;
}

Here is a demo of your events:

var events_array = [{
    title: '1\n2\n5\n8',
    start: new Date(2015, 9, 20),
}, {
    title: '5\n4\n1\n2',
    start: new Date(2015, 9, 21),
    tip: 'Personal tip 2'
}];

the \n is fundamental for the newline for the column number.

See:

Demo: http://jsfiddle.net/IrvinDominin/dcx5unzd/1/

这篇关于用于fullCalendar js的DOM操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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