将 calendar_date_select 链接到 ActiveScaffold 中的选择

发布于 2024-08-08 06:22:06 字数 685 浏览 3 评论 0原文

我正在尝试将 calendaer_date_select 链接到选择字段,以便选择列表按所选日期进行过滤。 描述的说明进行操作

我已按照这里我在activescaffold配置中 :

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

...在助手中:

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

问题是从 javascript 小部件中选择日期 不会触发选择刷新。但是如果我输入日期 然后就可以了。有什么想法吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

四叶草在未来唯美盛开 2024-08-15 06:22:06

这是 ActiveScaffold 的一个错误,已于今天早上修复。因此,再次克隆存储库将解决您的问题。

根据记录,ActiveScaffold 用于监视更改的方法无法捕捉日历日期选择设置字段的方式。 ActiveScaffold 监视字段上的更改事件以进行列更新。更改事件是由字段值在获得焦点和失去焦点之间的修改触发的。日历日期选择会修改值,而不给予或删除该字段的焦点。

如果您不想更新插件,您可以通过执行以下操作自行将其组合在一起

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

config.columns[:order_date].options = {:update_column => :sale, 
  :before_show => 'this.focus()', :onchange => 'this.blur()'}

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()'}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文