views:

232

answers:

1

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?

A: 

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
Thanks EmFi I will update AS and report back
Guy C