【问题标题】:showing both weekdays and weekends on the same fullcalendar在同一个日历上同时显示工作日和周末
【发布时间】:2012-11-12 10:28:23
【问题描述】:

我想在同一个完整日历上同时显示一周中的所有日子和工作日。我想在日历上有两个按钮,一个称为“周”,它已经在完整的日历上显示全天一周和其他称为“工作周”的按钮,点击后只会显示周末。 建议我这样做。

这是我的代码

<script type='text/javascript'>
$(function() { 
  var date = new Date(); 
  var d = date.getDate(); 
  var m = date.getMonth(); 
  var y = date.getFullYear(); 
  var calendar = $('#calendar').fullCalendar({ 
    header: { 
      left: 'prev,next today', 
      center: 'title', 
       right: 'agendaDay,agendaWeek,month' 
    }, 
    selectable: true, 
    selectHelper: true, 
    weekends:false, 
    defaultView: 'agendaWeek', 
    select: function(start, end, allDay) { //calendar.fullCalendar('unselect'); 
    },
    editable: true 
   }); 
 }); 
</script

【问题讨论】:

  • 这是日历的代码,其中我有三个按钮,但我想要一个称为工作周的额外按钮..点击后我应该只得到周末......
  • 请提供完整的代码...我不确定在 $("weekends") 中定义这个周末和工作周的位置...请帮助我...
  • 非常感谢。但是我现在面临的问题是,当我继续单击每个按钮时,相同的代码会重复出现,并且相同的视图会继续添加到同一页面上意味着同一个日历多次出现..那么如何解决这个..我可以使用.live(function)吗?

标签: php javascript fullcalendar


【解决方案1】:

FullCalendar switch between weekends and no weekends 的副本

所以这个答案只有在你从 DOM 中删除日历的前一个副本时才有效

http://arshaw.com/fullcalendar/docs/usage/

HTML:

<input type="button" id="weekends" value="Include weekends" />
<input type="button" id="workweek" value="Exclude weekends" />

JavaScript

$(function() {
  $("#weekends").on("click",function() {
    $('#calendar').fullCalendar({weekends:true});
  });
  $("#workweek").on("click",function() {
    $('#calendar').fullCalendar({weekends:false});
  });
});

要测试我的建议,请尝试粘贴此

javascript:(function() {$('#calendar').fullCalendar({weekends:false})})()

进入此页面的地址栏并按回车键(在 Fx 15+ 中使用控制台或创建书签)

http://arshaw.com/js/fullcalendar-1.5.4/demos/external-dragging.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多