https://github.com/doabit/city_picker
中国省市区街道四级联动地址选择器。
https://github.com/doabit/city_picker
Last synced: about 1 year ago
JSON representation
中国省市区街道四级联动地址选择器。
- Host: GitHub
- URL: https://github.com/doabit/city_picker
- Owner: doabit
- License: mit
- Created: 2018-07-03T02:10:09.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-03T02:11:23.000Z (almost 8 years ago)
- Last Synced: 2025-01-29T01:56:15.257Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 431 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: MIT-LICENSE
Awesome Lists containing this project
README
# CityPicker
中国省市区街道四级联地址选择,js代码来自 [city-picker](https://github.com/huangchanghuan/city-picker), 数据来自 [Administrative-divisions-of-China](https://github.com/modood/Administrative-divisions-of-China)
## 安装
### Gemfile
```ruby
gem 'city_picker'
```
### app/assets/javascripts/application.js
```javascript
//= require city_picker/city_picker
```
### app/assets/stylesheets/application.css
```javascript
*= require city_picker/city_picker
```
config/routes.rb
```ruby
mount CityPicker::Engine => "/city_picker"
```
## 使用
在页面中加入
```html
```
```javascript
$(function() {
$('#target').citypicker({
responsive: true,
simple: true,
// level: 'district'
// addrElm: '#addrValue1'
});
$('#target').on('cp:updated', function(e) {
console.log($(this).val())
})
})
```
如果要在选择后取得城市code,可在页面添加
```html
```
或者 添加初始化选项 `addrElm: '#my_address_elm`
```html
```
## Contributing
Contribution directions go here.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).