popup CDS inside an ajax form

2 views
Skip to first unread message

robert

unread,
Sep 22, 2009, 10:36:19 AM9/22/09
to calendar_date_select
Hi,

I have a simple form with a CS and submit. The form is a
form_remote_tag type. The ajax response replaces the partial which
contains the form.

It seems that in doing so, the widget cannot keep track of the
currently selected date, even though it is in the field value. I.e.
if I use the popup to select a date in 2013 - it's all good and that
date is submitted. However when I open the popup again, it show
todays date as the current date. So if I want to move by one date
(for example) I have to go and select the correct year and month
again.

Partial:
<% form_remote_tag :url=>{:action=>'submit'} do -%>
<%= calendar_date_select_tag('settlement_date', @date) -%>
<%= submit_tag %>
<% end -%>

Controller:
class WelcomeController < ApplicationController
def submit
@date = Date.parse(params[:settlement_date])
render :update do |page|
page.replace_html 'form_div', :partial=>'form'#escape_javascript
(:partial =>'form')
end
end
end

Am I missing something?

Thanks...

robert

unread,
Sep 23, 2009, 5:49:07 AM9/23/09
to calendar_date_select
Hmm this is weird. I notice that it doesn't matter about the ajax
part....

If I click the icon and select a date in 2013 (for example) and the
close the calendar, the text field shows the date I selected - all is
well.

If I immediately click the icon again (without submitting), the
calendar opens with the current date (i.e. todays date) selected!

I created another test view with just the following (as per the demo):

<%= calendar_date_select_tag "e_date" %>


And that has the same behavior, which is different from the demo....

Perhaps a new bug?

timcharper

unread,
Sep 24, 2009, 3:39:11 PM9/24/09
to calendar_date_select
I haven't ever heard of anything, so it may be a new bug. I suspect it
may be a parsing issue. Can you by chance trace in with firebug?

Check out line 337, 338 here:

http://is.gd/3DCEH

If the call to Date.parseFormattedString on 337 fails to return a
value, 338 defaults it to today. My stab would be that
Date.parseFormattedString (which is defined by the date format you
have loaded) isn't able to parse the date in the text box, and that's
causing the failure.

Another possibility is that CalendarDateSelect is unable to find your
input control. If that's the case though, it wouldn't be able to a
set a value to it once you select a date.

Tim

robert

unread,
Sep 26, 2009, 4:34:21 AM9/26/09
to calendar_date_select
Yes, that is what's happening. I'm using ISO date format. My
environment.rb has CalendarDateSelect.format = :iso_date

In Firebug console...

Date.parseFormattedString("2014-09-18")

...returns Invalid Date.

robert

unread,
Oct 3, 2009, 5:25:47 AM10/3/09
to calendar_date_select
Fixed up the parser and sent a pull request on Github.....
Reply all
Reply to author
Forward
0 new messages