Sha256: 196cf0d05af0dbdf3e9d4ce80bc63752937d7e8b5cfe02dc6fbd032d4221635d
Contents?: true
Size: 906 Bytes
Versions: 1
Compression:
Stored size: 906 Bytes
Contents
(($) -> $.fn.china_city = () -> @each -> selects = $(@).find('.city-select') selects.change -> $this = $(@) next_selects = selects.slice(selects.index(@) + 1) # empty all children city customfunc = if $this.data("customfunc") then $this.data("customfunc") else false $("option:gt(0)", next_selects).remove() if next_selects.first()[0] and $this.val() and !$this.val().match(/--.*--/) # init next child $.get "/china_city/#{$(@).val()}", (data) -> data = data.data if data.data? next_selects.first()[0].options.add(new Option(option[0], option[1])) for option in data # init value after data completed. if customfunc then eval(customfunc) next_selects.trigger('china_city:load_data_completed'); $(document).on 'ready page:load', -> $('.city-group').china_city() )(jQuery)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
china_city_custom-0.0.7 | app/assets/javascripts/china_city/jquery.china_city.js.coffee |