Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

city_picker

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

city_picker

bundlerRubygems
Version
0.1.0
Version published
Maintainers
1
Created
Source

CityPicker

中国省市区街道四级联地址选择,js代码来自 city-picker, 数据来自 Administrative-divisions-of-China

安装

Gemfile

gem 'city_picker'

app/assets/javascripts/application.js

//= require city_picker/city_picker

app/assets/stylesheets/application.css

*= require city_picker/city_picker

config/routes.rb

mount CityPicker::Engine => "/city_picker"

使用

在页面中加入

<div style="position: relative;">
  <!-- container -->
  <input readonly type="text"  placeholder="请选择省/市"  id="target" style="width:100%">
</div>
<script>
  $(function() {
    $('#target').citypicker({
      responsive: true,
      simple: true,
      // level: 'district'
      // addrElm: '#addrValue1'
    });

    $('#target').on('cp:updated', function(e) {
      console.log($(this).val())
    })
  })
</script>

如果要在选择后取得城市code,可在页面添加

<input type="text" id="addrValue">

或者 添加初始化选项 addrElm: '#my_address_elm

 <input type="text" id="my_address_elm">

Contributing

Contribution directions go here.

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 03 Jul 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts