Nav apraksta

saberma 9e7898be25 add appraisals config: support rails3.1, 3.2, and 4.0 10 gadi atpakaļ
app 17dc9d92d3 fixed #3, select other province should clean children selects. 10 gadi atpakaļ
bin 21230b97bd init. 10 gadi atpakaļ
config cd9363d89b show select. 10 gadi atpakaļ
db 8cc5a049e2 config rspec. 10 gadi atpakaļ
gemfiles 9e7898be25 add appraisals config: support rails3.1, 3.2, and 4.0 10 gadi atpakaļ
lib b4d3757465 update version v0.0.2 10 gadi atpakaļ
spec 2b05d821d2 add rspec sleep. 10 gadi atpakaļ
.gitignore 21230b97bd init. 10 gadi atpakaļ
.rspec 8cc5a049e2 config rspec. 10 gadi atpakaļ
.travis.yml 1c45686de0 add travis config. 10 gadi atpakaļ
Appraisals 9e7898be25 add appraisals config: support rails3.1, 3.2, and 4.0 10 gadi atpakaļ
Gemfile 9e7898be25 add appraisals config: support rails3.1, 3.2, and 4.0 10 gadi atpakaļ
Gemfile.lock 9e7898be25 add appraisals config: support rails3.1, 3.2, and 4.0 10 gadi atpakaļ
MIT-LICENSE 8e4256923e add MIT licentse to gemspec. 10 gadi atpakaļ
README.md 766c230834 typo fixed. 10 gadi atpakaļ
Rakefile b399f86669 add appraisals gem. 10 gadi atpakaļ
china_city.gemspec 9e7898be25 add appraisals config: support rails3.1, 3.2, and 4.0 10 gadi atpakaļ

README.md

ChinaCity 省市区级联选择

Build Status

china_city

简介

这是一个基于 Rails Engine 开发的插件,为 Rails 项目增加省市区三级(或者省市 二级)选择框,可用于实现收货地址等信息的录入。

安装

Gemfile

gem 'china_city'

app/assets/javascripts/application.js

//= require 'jquery'
//= require 'china_city/jquery.china_city'

config/routes.rb

mount ChinaCity::Engine => '/china_city' if defined?(ChinaCity)

使用

在页面中加入选择框,示例代码使用 slim 格式

  .city-group
    select.city-select
      option --省份--
      = options_for_select(ChinaCity.list)
    select.city-select
      option --城市--
    select.city-select
      option --地区--

请留意:所有选择框都要有 city-select class,并都包含于 class='city-group' 的 DOM 元素之下。

选择后的值为国家地区编码,如深圳市的为 440300,可通过调用 ChinaCity.get('440300') 将编码转化为城市名称。

贡献

git clone git@github.com:saberma/china_city.git
cd china_city
cd spec/dummy
rails server # http://localhost:3000/china_city

类似项目