Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
三级联动地区选择器(目前不兼容rails4)
Ruby JavaScript CSS
Branch: master

Update README.md

remove online demo
latest commit 10e6e096f0
@Kehao authored
Failed to load latest commit information.
app/assets move vender to app for rails 4
config first commit
lib add rails rspec
spec add rails rspec
.gitignore modified: Rakefile :smile:
.rspec
.travis.yml remove script rake db:test:prepare
Gemfile add rails rspec
Gemfile.rails4 add rails rspec
Gemfile.rails4.lock
LICENSE.txt Hello :notes:
README.md Update README.md
Rakefile modified: Rakefile :smile:
district_cn_selector.gemspec add helper test for form and simple form

README.md

Gem Version Build Status

地区选择插件

三级联动地区选择器:

  1. select-ul 模拟下拉菜单
  2. select 下拉菜单

Features

  1. 支持bootstrap
  2. 支持simple_form
  3. 支持select和select-ul
  4. 基于district_cn,有一些实用的方法

TODO

*兼容rails4 *

Installation

Add it to your Gemfile:

gem 'district_cn_selector'

And then execute:

bundle install

Add it to your application.js:

// select
//= require district_cn_selector/jquery.district
// select-ul
//= require district_cn_selector/jquery.district-ul

if you want to use the default theme, add it to your application.css:

*= require  district_cn_selector/district-ul

FormHelper

form_tag

<%= form_tag "" do %>
<!-- select -->
  <%= district_select(:company,:region_code,"331000") %>

<!-- select-ul -->
  <%= district_select_ul(:company,:region_code,"331000") %>
<% end %>

form_for

<%= form_for Company.new,:builder => DistrictCnSelector::Helpers::FormBuilder do |f| %>
<!-- select -->
  <%= f.district_select :region_code%>

<!-- select-ul -->
  <%= f.district_select_ul :region_code%>
<%end%>

simple_form_for

<%= simple_form_for Company.new,:html => { :class => 'form-horizontal' } do |f| %>
<!-- select -->
  <%= f.input :region_code,:as => :district_select %>

<!-- select-ul -->
  <%= f.input :region_code,:as => :district_select_ul %>
<% end %>

province,city,district select helper

<!-- select,select-ul适用 -->
<!-- form_tag -->
<%= district_select_ul(:company,:region_code,"331000") %>
<%= city_select_ul(:company,:region_code,"331000") %>
<%= province_select_ul(:company,:region_code,"331000") %>

<!-- form_for -->
<%= f.district_select_ul :region_code %>
<%= f.city_select_ul :region_code %>
<%= f.province_select_ul :region_code %>

<!-- simple_form_for -->
<%= f.input :region_code,:as => :district_select_ul %>
<%= f.input :region_code,:as => :city_select_ul %>
<%= f.input :region_code,:as => :province_select_ul %>

Theme(select-ul适用)

  1. default
  2. bootstrap

if you want to use the default theme, add it to your application.css:

*= require district_cn_selector/district-ul

if you want to use bootstrap theme, you should import bootstrap css.

<!-- form_tag -->
<%= district_select_ul(:company,:region_code,"331000",:theme=>:bootstrap) %>

<!-- form_for -->
<%= f.district_select_ul :region_code,:theme=>:bootstrap,:prompt_class=>"btn btn-success"%>

<!-- simple_form_for,如果SimpleForm.wrapper等于:bootstrap,默认样式为:bootstrap -->
<%= f.input :region_code,:as => :district_select_ul %>

Test

  rake spec

Resources

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
Something went wrong with that request. Please try again.