0

I am trying to chain a calendaer_date_select to a select field, so the select list is filtered by the choosen date. I have followed the instructions as described here

I have in the activescaffold config:

config.columns[:order_date].form_ui = :calendar_date_select
config.columns[:order_date].options = {:update_column => :sale}
config.columns[:sale].form_ui = :select

... and in the helper:

def options_for_association_conditions(association)
  if association.name == :sale
    {'sales.order_date' => @record.order_date}
  else
    super
  end
end

The problem is that picking a date from the javascript widget thingy doesn't trigger the select to refresh. However if I type in the date then it does. Any ideas?

whizcreed
  • 2,700
  • 3
  • 22
  • 35
Guy C
  • 6,970
  • 5
  • 30
  • 30
  • I have used ActiveScaffold for some time and it's not the best one to use if you want to be on the edge of RoR. They don't do updated on timely basis and I had to patch it myself several times. Not offering this as an answer but more of an advise. – Zepplock Oct 26 '09 at 05:35
  • This was a bug with ActiveScaffold. I submitted a ticket and fix last night. This morning the master repository was updated with a fix. Update the plugin and it will work as advertised. – EmFi Oct 26 '09 at 17:15

1 Answers1

0

This was a bug with ActiveScaffold that was fixed this morning. So cloning the repository again will solve your problems.

For the record, the method ActiveScaffold uses to watch for changes doesn't catch the way that Calendar Date Select sets the field. ActiveScaffold watches for change events on fields for column updates. Change events are triggered by a modification in a fields value between the time it gains and loses focus. Calendar Date Select modifies the value without giving or removing focus to the field.

If you don't feel like updating your plugins, you could hack it together your self by doing the following:

config.columns[:order_date].options = {:update_column => :sale}

to

config.columns[:order_date].options = {:update_column => :sale, 
  :before_show => 'this.focus()', :onchange => 'this.blur()'}
EmFi
  • 23,435
  • 3
  • 57
  • 68