Sha256: fe9074204f373be24506689c98e9c2a472449c744492b51d1096be9e6db9775e

Contents?: true

Size: 717 Bytes

Versions: 1

Compression:

Stored size: 717 Bytes

Contents

(($) ->
  $.fn.china_city = () ->
    @each ->
      selects = $(@).find('.city-select')
      selects.change ->
        $this = $(@)
        next_selects = selects.slice(selects.index(@) + 1) # empty all children city
        $("option:gt(0)", next_selects).remove()
        if next_selects.first()[0] and $this.val() # init next child
          $.get "/china_city/#{$(@).val()}", (data) ->
            next_selects.first()[0].options.add(new Option(option[0], option[1])) for option in data.data
            # init value after data completed.
            next_selects.trigger('china_city:load_data_completed');
        $this.blur()
  $(document).on 'ready page:load', ->
    $('.city-group').china_city()
)(jQuery)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
china_citys-0.0.5 app/assets/javascripts/china_citys/jquery.china_citys.js.coffee