2011-09-19 59 views
0

我正在使用带轨道2.3.8的event_calendar插件。我有名称,场地和教练列的事件表。我想要根据教练和场地进行颜色比赛。我可以通过培训师给它着色。但是现在我想将参数传递给活动日历助手,考虑它是否是培训师或场地。我应该如何传递这个参数?任何人使用这个插件? plz帮助我....如何将参数传递给事件日历助手?

回答

1

如果你看一看README.rdoc你会得到

<%= event_calendar %> 


==Default Options 

The default options for the calendar are: 

    defaults = { 
    :year => Time.zone.now.year, 
    :month => Time.zone.now.month, 
    :abbrev => true, 
    :first_day_of_week => 0, # See note below when setting this 
    :show_today => true, 
    :month_name_text => Time.zone.now.strftime("%B %Y"), 
    :previous_month_text => nil, 
    :next_month_text => nil, 
    :event_strips => [], 

    # it would be nice to have these in the CSS file 
    # but they are needed to perform height calculations 
    :width => nil, 
    :height => 500, 
    :day_names_height => 18, 
    :day_nums_height => 18, 
    :event_height => 18, 
    :event_margin => 1, 
    :event_padding_top => 1, 

    :use_all_day => false, 
    :use_javascript => true, 
    :link_to_day_action => false 
    } 

我采取以下我的日历两个参数并覆盖插件在

<%= event_calendar(user.format, outbound) %> 
helper方法

应用程序/佣工/ calendar_helper.rb

def event_calendar_opts(display_format, outbound) 
    { 
     :year => @year, 
     :month => @month, 
     :abbrev => nil, 
     :event_strips => @event_strips, 
     :display_properties => (display_format==4)? 4 : 3, 
     :outbound => outbound, 
     :month_name_text => I18n.localize(@shown_month, :format => "%B %Y"), 
     :previous_month_text => month_link(@shown_month.last_month), 
     :next_month_text => next_month_link(@shown_month.next_month) } 
    end 

    def event_calendar(display_format, outbound) 
    # args is an argument hash containing :event, :day, and :options 
    index = 0 
    calendar event_calendar_opts(display_format, outbound) do |args| 
     html << some_html 
     html 
    end 
    end 
+0

我可以传递参数给供应商\插件\ event_calendar \ LIB \ event_calendar \日历助手如上?我试图通过它。但是有错误。 – Rosh

+0

@Rosh:是的,您可以使用上述方法将参数传递给您的插件的帮助器方法。在我的例子中,你可以像下面的'options [:display_properties]'一样在插件的帮助器中获取参数。一个重要的,也就是每当你改变你的插件重新启动我们的服务器。 – Salil

相关问题