不会根据所选国家/地区加载状态



各位,我使用的是country_state_select gem,在从文档中输入代码后,country和state select标签会正确显示在表单视图中,但即使在选择了一个国家后,这些州也不会加载,我看到的只有美国的州,我添加了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。

我刚刚找到了一个解决方案。测试和工作。发现它在宝石本身,内部问题。。。

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

包括此代码:

<%=javascript_include_tag"country_state_select"%><%=javascript_tag do%>$(document).on('ready page:load',function(){
return CountryStateSelect({country_id:"国家",state_id:"state"});});

但是需要在config/ininitializers/assets.rb 中增加一行

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

感谢@loganh0522解决方案是4天前的。。。

最新更新