【问题标题】:how to change the event_calendar plugin to show by week instead by month? [duplicate]如何将 event_calendar 插件更改为按周而不是按月显示? [复制]
【发布时间】:2011-09-18 04:07:21
【问题描述】:

可能重复:
how to customize the table builder plugin for a week calendar ?

我使用 event_calendar 插件,git 存储库:

https://github.com/elevation/event_calendar

我需要自定义此日历以按周而不是按月显示,我该怎么做?

这是我的控制器:

def index
    do_withs = DoWith.where(:friend_id => current_user.id)
    @statuses = do_withs.collect { |f| f.status_id }
    @statuses = @statuses.collect { |f| Status.find(f) }
    @statuses = @statuses + current_user.statuses 
    @statuses.flatten!
    @date = params[:month] ? Date.parse(params[:month]) : Date.today
  end

这是我的观点:

<div id="calendar">
  <h2 id="month">
     <%= link_to "<", :month => (@date.beginning_of_month-1).strftime("%Y-%m-%d") %>
    <%=h @date.strftime("%B %Y") %>
 <%= link_to ">", :month => (@date.end_of_month+1).strftime("%Y-%m-%d") %>
  </h2>
  <% calendar_for @statuses, :year => @date.year, :month => @date.month do |calendar| %>
    <%= calendar.head('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday') %>
    <% calendar.day(:day_method => :date) do |date, statuses| %>
      <%= date.day %>
      <ul>
        <% for status in statuses %>
          <li><%= link_to h(status.content), status %></li>
        <% end %>
      </ul>
    <% end %>
  <% end %>
</div>

这几天让我发疯了,如果有人知道我该如何定制这个日历,请告诉我。 谢谢分配。

【问题讨论】:

标签: html ruby-on-rails ruby plugins github


【解决方案1】:

这个插件的功能非常有限,不可能按周显示事件。

还有一个基于 jQuery 的替代解决方案。

http://arshaw.com/fullcalendar/

我刚刚为它找到了 rails 后端:

https://github.com/bokmann/rails3_fullcalendar

【讨论】:

    猜你喜欢
    • 2020-10-13
    • 1970-01-01
    • 2021-06-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-06
    • 1970-01-01
    相关资源
    最近更新 更多