Before I starting writing a helper to display a calendar I wondered if anyone was aware of a calendar helper, basically something that is displayed inline (not a pop-up window) that can replace a date_select. The way I am thinking of doing it is to have a partial which is passed a Time class, the month is extracted from the date and a grid displayed for that month. Which should not be to difficult since there are some nice constants in Date class which include the number of days in a month for normal and leap years. Each date will have a javascript onclick which will pass its value (eg. 3 if you clicked on the 3rd) to a javascript function which would store the value in a hidden field. Those hidden fields may translate directly in to a date when parsed by Rails or they may need to be done manually using Time.parse. Now the problem comes when the user needs to change the month since only one month can be displayed at a time. So I have a link for the next and previous month, when clicked the grid is replaced with the correct month''s grid. How best to do this, im thinking ajax would be the wrong choice and I may be better to do it all client side using javascript, but then I dont get access to the partical... so ajax it must be?? -- Posted via http://www.ruby-forum.com/.
On Tue, 2006-07-04 at 15:03 +0200, AFM wrote:> Before I starting writing a helper to display a calendar I wondered if > anyone was aware of a calendar helper, basically something that is > displayed inline (not a pop-up window) that can replace a date_select. > > The way I am thinking of doing it is to have a partial which is passed a > Time class, the month is extracted from the date and a grid displayed > for that month. Which should not be to difficult since there are some > nice constants in Date class which include the number of days in a > month for normal and leap years. > > Each date will have a javascript onclick which will pass its value (eg. > 3 if you clicked on the 3rd) to a javascript function which would store > the value in a hidden field. > > Those hidden fields may translate directly in to a date when parsed by > Rails or they may need to be done manually using Time.parse. > > Now the problem comes when the user needs to change the month since only > one month can be displayed at a time. So I have a link for the next and > previous month, when clicked the grid is replaced with the correct > month''s grid. > > How best to do this, im thinking ajax would be the wrong choice and I > may be better to do it all client side using javascript, but then I dont > get access to the partical... so ajax it must be??---- why reinvent wheel? http://wiki.rubyonrails.org/rails/pages/DatePicker Craig
Check out this calendar http://www.dynarch.com/projects/calendar/. It is very nice and I am using it in a couple applications. I wrote a couple of my own helpers when using the dynarch calendar, but you could use http://rails-engines.org/wiki/pages/DateboxEngine rather that write your own. mark On 7/4/06, Craig White <craigwhite@azapple.com> wrote:> > On Tue, 2006-07-04 at 15:03 +0200, AFM wrote: > > Before I starting writing a helper to display a calendar I wondered if > > anyone was aware of a calendar helper, basically something that is > > displayed inline (not a pop-up window) that can replace a date_select. > > > > The way I am thinking of doing it is to have a partial which is passed a > > Time class, the month is extracted from the date and a grid displayed > > for that month. Which should not be to difficult since there are some > > nice constants in Date class which include the number of days in a > > month for normal and leap years. > > > > Each date will have a javascript onclick which will pass its value (eg. > > 3 if you clicked on the 3rd) to a javascript function which would store > > the value in a hidden field. > > > > Those hidden fields may translate directly in to a date when parsed by > > Rails or they may need to be done manually using Time.parse. > > > > Now the problem comes when the user needs to change the month since only > > one month can be displayed at a time. So I have a link for the next and > > previous month, when clicked the grid is replaced with the correct > > month''s grid. > > > > How best to do this, im thinking ajax would be the wrong choice and I > > may be better to do it all client side using javascript, but then I dont > > get access to the partical... so ajax it must be?? > ---- > why reinvent wheel? > > http://wiki.rubyonrails.org/rails/pages/DatePicker > > Craig > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Mark Van Holstyn mvette13@gmail.com http://lotswholetime.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060704/5b3e2919/attachment.html