Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.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
用jQuery Fullcalendar中事件的链接替换天数_Jquery_Events_Fullcalendar - Fatal编程技术网

用jQuery Fullcalendar中事件的链接替换天数

用jQuery Fullcalendar中事件的链接替换天数,jquery,events,fullcalendar,Jquery,Events,Fullcalendar,我正在使用arshaw.com/Fullcalendar/上的jQuery Fullcalendar,我想用指向事件的链接来替换日期,这是我通过JSON从数据库获得的,如: 我有一个每天只有一个活动的小日历,所以默认显示对我来说是不必要的。我需要更简单更干净的东西 因为我对jQuery不是很熟悉,所以我自己也无法理解 有没有办法取代这个: <div class="fc-day-number">5</div> 5 使用当天事件的链接?无需修改日历创建脚本的源代码,只需稍

我正在使用arshaw.com/Fullcalendar/上的jQuery Fullcalendar,我想用指向事件的链接来替换日期,这是我通过JSON从数据库获得的,如:

我有一个每天只有一个活动的小日历,所以默认显示对我来说是不必要的。我需要更简单更干净的东西

因为我对jQuery不是很熟悉,所以我自己也无法理解

有没有办法取代这个:

<div class="fc-day-number">5</div>
5

使用当天事件的链接?

无需修改日历创建脚本的源代码,只需稍加修改即可获得所需的结果。假设您有一个JavaScript对象,它保存您的事件URL,如下所示:

var urls = {
    4: "http://mydomain.com/event.html",
    16: "http://mydomain.com/event2.html",
    22: "http://mydomain.com/event.html"
}
这可能是JSON请求的结果。然后,您可以循环查看日历中的所有日期,并检查是否有该日期的链接,然后更新日期编号以包含链接:

$('.fc-day-number').each(function() {
    // Get current day
    var day = parseInt($(this).html());

    // Check if there's a url defined for the day
    if(urls[day] != undefined) {
        // Replace the day number with the link
        $(this).html('<a href="' + urls[day] + '">' + day + '</a>');
    }
});
$('.fc日数')。每个(函数(){
//获取当前日期
var day=parseInt($(this.html());
//检查是否为当天定义了url
如果(URL[日期]!=未定义){
//将日数替换为链接
$(this.html(“”);
}
});

只要在每次加载/打开日历时运行该代码段即可。如果不了解有关日历的更多信息,就无法说出此代码段的确切位置。

您只需快速修改fullcalendar.js即可

  • 在创建时添加链接
  • 在Cellles重新绘制的内容中添加链接
只需替换此行:

(showNumbers ? "<div class='fc-day-number'>" + d.getDate() + "</div>" : '') +
(showNumbers ? "<div class='fc-day-number'><a href=\"myURL.com\">" + d.getDate() + "</a></div>" : '') +
td.find('div.fc-day-number').text(d.getDate());
td.find('div.fc-day-number').html("<a href=\"myURL.com\">"+d.getDate()+"<a\>");
这一行:

(showNumbers ? "<div class='fc-day-number'>" + d.getDate() + "</div>" : '') +
(showNumbers ? "<div class='fc-day-number'><a href=\"myURL.com\">" + d.getDate() + "</a></div>" : '') +
td.find('div.fc-day-number').text(d.getDate());
td.find('div.fc-day-number').html("<a href=\"myURL.com\">"+d.getDate()+"<a\>");
td.find('div.fc-day-number').html(“+d.getDate()+”);
享受它;)