ProtoCalendarを試す
これ
http://labs.spookies.jp/product/protocalendar
ヘルパーに仕込む
def date_field(object_name, method, options = {}) result = text_field_for_date(object_name, method, options) styleId = options[:id] ? options[:id] : object_name.to_s + '_' + method.to_s contents = "InputCalendar.createOnLoaded('#{styleId}', {"; lang = options[:lang] ? "lang:#{options[:lang]} " : "lang:'ja'" contents << lang contents << ", startYear:#{options[:startYear]} " if options[:startYear] contents << ", endYear:#{options[:endYear]} " if options[:endYear] contents << "});"; return (result + javascript_tag(contents)) end protected def text_field_for_date(object_name, method, options = {}) tag = InstanceTag.new(object_name, method, self, nil, options.delete(:object)) result = tag.value(tag.object) unless result.nil? time = result.strftime("%Y/%m/%d") tag.object.write_attribute(method, time) unless tag.nil? end return tag.to_input_field_tag("text", options) end
ビューに召喚呪文
<% content_for :html_header do -%> <%= javascript_include_tag 'protocalendar/protocalendar' %> <%= javascript_include_tag 'protocalendar/lang_ja' %> <%= stylesheet_link_tag 'protocalendar/simple' %> <% end -%>
フォームの中、書き換える
<%#= date_select(:hoge, :booked_day) %> <%= date_field(:hoge, :booked_day) %>
firebug様がエラーを出す
calrndr.getPrevButton().observe is not a function protocalendar.js (line 619)
うーん・・・
prototype.jsとかeffecs.jsを最新版とかにすると動くんだけど、autp_completeで被害が出る。困った困った・・・