Using calendar_select in DHTML Calendar plugin for rails
The DHTML / JavaScript Calendar is a javascript library for creating customized calendars. The library has been ported as a rails plugin, dhtml calendar.
Using calendar_select from this plugin, I found that the date time fields were not being updated after I picked up a date from date select popup. I had to modify lines 27-35 in calendar.rb from
if show_field == :select
input_field_year_id = "#{object}[#{method}(1i)]"
input_field_month_id = "#{object}[#{method}(2i)]"
input_field_day_id = "#{object}[#{method}(3i)]"
if calendar_options.has_key?(:showsTime) and calendar_options[:showsTime]
input_field_hour_id = "#{object}[#{method}(4i)]"
input_field_minute_id = "#{object}[#{method}(5i)]"
end
end
to
if show_field == :select
input_field_year_id = "#{object}_#{method}_1i"
input_field_month_id = "#{object}_#{method}_2i"
input_field_day_id = "#{object}_#{method}_3i"
if calendar_options.has_key?(:showsTime) and calendar_options[:showsTime]
input_field_hour_id = "#{object}_#{method}_4i"
input_field_minute_id = "#{object}_#{method}_5i"
end
end
The plugin internally uses datetime_select and date_select to create year select with DOM id as “#{object}_#{method}_1i” and DOM name as “#{object}[#{method}(1i)]“. The DOM name variable was been referenced in the calendar.rb which did not update the fields when user tries to pick a date from popup. On changing this to DOM id variable, everything worked fine.
Ruby Funday : A Day full of Ruby Fun
The first ruby full day event of its kind is to be held on 22nd November, 2008 at Impetus, Noida.
Here are the highlights of the day…
- Flex on Rails
- Internationalization Rails
- FxRuby & ActiveRecord
- Facebook App on Rails
- Integrating Voice gateways in Rails
- Soft Rock

More details on event and venue can be found at rubyonrails.in
See you there.
Next,

