Coder Social home page Coder Social logo

elliotcui / china_city Goto Github PK

View Code? Open in Web Editor NEW

This project forked from saberma/china_city

0.0 2.0 0.0 718 KB

省市区街道四级联选择 Rails Engine Gem

Home Page: http://china-city-example.herokuapp.com/

License: MIT License

Ruby 80.96% CoffeeScript 1.88% CSS 2.43% HTML 13.26% JavaScript 1.47%

china_city's Introduction

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'

使用

可以参考 https://github.com/saberma/china_city_example 示例代码。

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

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

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

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

更新

  • 0.0.5 更新省市区数据到最新的国标,支持街道

贡献

git clone [email protected]:saberma/china_city.git
cd china_city
rake appraisal:install
cd spec/dummy
rails server
open http://localhost:3000/china_city

测试

brew install phantomjs    # http://git.io/vRJ1M
rvm use 2.1               # Fixed: NoMethodError: undefined method `using' for GB2260::Division:Class
rake appraisal:install
rake appraisal:rails4 spec

类似项目

china_city's People

Contributors

huhuanming avatar saberma avatar topcatv avatar yuc-zhu avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.