Chaining a calendar_date_select to a select in ActiveScaffold
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
开发者_如何学C
... 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?
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()'}
精彩评论