some problems dealing with a date_select helper. Here's the basic
situation that I already have working. I have a table and a live search
page where a user can type in partial phrases to match against the
various fields. Most of the fields are text_fields, but there is a
text_field_with_auto_complete and a select as well. I have an
observe_field for each input field and it builds up a search query and
updates the search results. All of these fields are in a
form_remote_for form so I can do all the AJAX goodness. So far so good.
Now we want to add a field that is a datetime. The first problem I see
with the date_select is that it has default values, as opposed to being
blank until filled in like the other fields. I don't want the search
narrowed by this date field until the user actually sets part of the
date. After some thought I disabled the fields on page load and added a
checkbox to enable the fields, so it visually looks like it's not part
date_select fields as the user checks the box. This is where things
start getting ugly.
1) Can I specify the name of the form_remote_for somehow? Nothing I
tried worked right. My current jury-rig is to get document.forms,
but that's a little brittle - if I add another partial it might move to
forms or the like. Looking at the page source there's no name given
Specifically they end up being something like
"text_line[recording_submit_date(1i)]" So I can reference
document.forms.checkboxname.checked, but I can't reference
document.forms.text_line[recording_submit_date(1i)]. How do I get
3) I punted on that for now and grabbed *them* by numeric ID (like
this: form.childNodes.childNodes) That's even *more* brittle and
is going to break the next time I touch this form, but it was a start.
Now I'm finding that I can't create an observe_field helper either, and
I'm guessing that might be due to the crazy names.
I realize that there are probably other plug-ins I can get to handle
date fields differently, but this seems like a simple problem, but it's
also one of those problems where at four hours ago I started on
something I expected to spend 30 minutes on and I'm still at it. If
anybody knows a solution that uses the default Rails date_select I'd
love to hear it.