Ajax Date Selector or similar?

I’ve been trying to find a date picker that works really well with
Rails. I’ve looked into the following thus far:

jMaki Widget jQuery.datepicker
jRails jQuery.datepicker

However, none of these provide any information on how to use them with
Rails. I’ve scrounged the web for tutorials or any information about
jQuery but most are either very out of date, or don’t have any substance
that I can work through.

Can anyone recommend something that will allow me to do the following:

User visits “x” page that contains a pre-populated table view.
User clicks on “y” button/widget/etc.
User selects a date (either from a drop down or a calendar widget)
Date is sent to a find/search parameter.
Data for the pre-populated table view is refreshed to show the new
criteria based on date.

I would believe that people who use rails would be using many types of
datepickers/selectors/etc. I’m surprised to see that there is very
little documentation about this area. Rails and ajax go hand in hand…

Maybe my google is broke…

Älphä Blüë wrote:

I’ve been trying to find a date picker that works really well with
Rails. I’ve looked into the following thus far:

jMaki Widget jQuery.datepicker
jRails jQuery.datepicker

However, none of these provide any information on how to use them with
Rails.

Every JS date picker I’m aware of populates a form field. Just submit
the form containing that field, and you’ll get the data you want.
There’s nothing magical about it.

[…]

I’m surprised to see that there is very
little documentation about this area.

There’s really nothing to document, provided you understand how forms
are submitted in Rails.

Rails and ajax go hand in hand…

Not really. Rails provides a few canned Ajax helpers (that probably
should be avoided in any case – or used with lowpro – since they
generate inline JS), and deals nicely with XML and JSON requests, but
that’s about it. (I’ve done complex Ajax development, but never with
Rails.)

Maybe my google is broke…

No, I think you’re looking for an explanation of something that’s too
trivial for most people to write about.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Hi Marnen,

Yeah I suppose I should have been more precise as to what I was trying
to find. I did find something that will work with what I’m after:

http://agilewebdevelopment.com/plugins/calendariffic_0_1_0

I wanted something that worked as a widget that had a nice theme, was
easy to style, and easy to date convert. Using this I can do the
following:

<%= calendariffic_input(false, :compiled_on, ‘calendariffic/date.png’,
‘search_cal’, ‘%Y-%m-%d’, @todays_date, {}, {:class => ‘borderless’})
%>

Pretty easy method call and the documentation in the file matches
something I can read pretty easily. I changed the dateformat, the
name/id, and can pass this along to my named_scope to generate the date.

Now I just have to figure out whether I need to use an actual submit
button or whether I can find something that works like an OnChange or an
observer method. I’d like it so that when someone presses the calendar
widget and selects the date, a notifier method changes the data…

I’ll look into it…

Okay I got it to work with the form submit and everything is searching
and submitting fine.

However, I have a question regarding the url links and submits and
default behavior. This might be an easy question for most so I
apologize in advance.

I have a main table in my index along with 2 search forms.

One search form basically allows a search of team names within the
database.
One search form allows a search for all data within distinct specific
date ranges.
The default table view shows all data compiled for the current week.

So, using the default table view if I go to my site the url is going to
be something like:

localhost.com/page

If I use the search for teams the link is going to be:

localhost.com/page?search=NameOfTeam

If I use the search for dates the link is going to be:

localhost.com/page?on_compiled=2009-06-30

as an example of todays dates…

Now, that’s all fine and dandy and they work, but since I use pagination
and sort table views, that functionality defaults back to the root url.

For instance, I pull todays date and get:

localhost.com/page?on_compiled=2009-06-30

and then click ASC sort button next to a team…

localhost.com/page

and the special date criteria is gone.

I would like to implement this particular page so that all search forms
and default behavior is similar…

localhost.com/page?search=nil&compiled_on=2009-06-30&sort=ASC

etc…

I know how to do this in PHP but not with rails. I’m just looking for
some pointers…