【问题标题】:states are not loaded according to selected country未根据所选国家/地区加载州
【发布时间】:2015-11-06 03:55:57
【问题描述】:

请大家,我正在使用 country_state_select gem,在输入文档中的代码后,国家和州选择标签在表单视图上正确显示,但是即使选择了一个国家,也没有加载州,只有州我看到的是美利坚合众国(美国)的州,我添加了我的 javascript,但问题仍然存在。 这是我下面的 .js 文件

$(document).on('ready page:load', function() {

return CountryStateSelect({
country_id: "admin_country",
state_id: "admin_state"
})
})

admin_country 和 admin_state 分别是 country 和 state 字段的我的 ID。

【问题讨论】:

  • 你解决了吗?我有同样的问题。 CountryStateSelect 产生一个未捕获的 ReferenceError,与 .css.scss 中的 @import "chosen" 的情况相同...一切就绪,id 没问题, gem country_state_select 似乎缺乏更好的配置...

标签: ruby-on-rails


【解决方案1】:

我刚刚找到了解决方案。测试和工作。在 gem 本身找到它,内部问题...

https://github.com/arvindvyas/Country-State-Select/issues/31

包括此代码:

$(document).on('ready page:load', function() {
返回国家状态选择({ country_id: "国家", state_id: "状态" }); });

但需要在 config/initializers/assets.rb 处增加一行

Rails.application.config.assets.precompile += %w( country_state_select.js)

感谢@loganh0522 解决方案来自 4 天前...

【讨论】:

  • 不,我无法解决这个问题,但无论如何我都会试试你的......谢谢
猜你喜欢
  • 1970-01-01
  • 2022-11-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-02-27
  • 2021-10-27
  • 1970-01-01
相关资源
最近更新 更多