Sha256: 7aa4685c74b6785a5dee1b6b31bfd668f5b1ec14e8b3f2b92c59959094d1f9f6

Contents?: true

Size: 548 Bytes

Versions: 2

Compression:

Stored size: 548 Bytes

Contents

(($) ->
  $.fn.taiwan_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 "/taiwan_city/#{$(@).val()}", (data) ->
            next_selects.first()[0].options.add(new Option(option[0], option[1])) for option in data

  $ ->
    $('.city-group').taiwan_city()
)(jQuery)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
taiwan_city-0.0.4 app/assets/javascripts/taiwan_city/jquery.taiwan_city.js.coffee
taiwan_city-0.0.3 app/assets/javascripts/taiwan_city/jquery.taiwan_city.js.coffee