0

出于某种原因,我SyntaxError: unexpected POST_IF在这段代码中的某个地方。有任何想法吗?-

$('.provider-fields').hide()
  switch parseInt($('#referral_provider_type').val())
    when window.AIDIN.provider_types.hha
      $('.hha-fields').show()
    when window.AIDIN.provider_types.snf
      $('.snf-fields').show()
      $("#length_of_stay").show()
      if ( $("#regular").hasClass('active') )
        $("#search_radius").show()
        if ( $("#search_radius input").val() == '' )
          $("#search_radius input").val window.AIDIN.radii.snf_radius
    when window.AIDIN.provider_types.ltac
      $('.ltac-fields').show()
      if ( $("#regular").hasClass('active') )
        $("#search_radius").show()
        if ( $("#search_radius input").val() == '' )
        $("#search_radius input").val window.AIDIN.radii.ltac_radius
    when window.AIDIN.provider_types.pd
      $('.pd-fields').show()
    when window.AIDIN.provider_types.irf
      $('.irf-fields').show()
      if ( $("#regular").hasClass('active') )
        $("#search_radius").show()
        if ( $("#search_radius input").val() == '' )
        $("#search_radius input").val window.AIDIN.radii.irf_radius

  $('#referral_provider_type').live 'change', (e) ->
    $('.provider-fields').hide()
    $('input[type="checkbox"][name*="referral[referral_care_types_attributes]"]').attr("checked", false)
    switch parseInt($('#referral_provider_type').val())
      when window.AIDIN.provider_types.hha
        $('.hha-fields').show()
      when window.AIDIN.provider_types.snf
        $('.snf-fields').show()
        $("#length_of_stay").show()
        if ( $("#regular").hasClass('active') )
          $("#search_radius").show()
          if ( $("#search_radius input").val() == '' ) 
          $("#search_radius input").val window.AIDIN.radii.snf_radius
      when window.AIDIN.provider_types.ltac
        $('.ltac-fields').show()
        if $( ("#regular").hasClass('active') )
          $("#search_radius").show()
          if ( $("#search_radius input").val() == '' )
          $("#search_radius input").val window.AIDIN.radii.ltac_radius
      when window.AIDIN.provider_types.pd
        $('.pd-fields').show()
      when window.AIDIN.provider_types.irf
        $('.irf-fields').show()
        if ( $("#regular").hasClass('active')   )
          $("#search_radius").show()
          if ( $("#search_radius input").val() == '' )
          $("#search_radius input").val window.AIDIN.radii.irf_radius
4

1 回答 1

2

缩进问题如下图:

  switch parseInt($('#referral_provider_type').val())
    when window.AIDIN.provider_types.hha
      $('.hha-fields').show()
    when window.AIDIN.provider_types.snf
      $('.snf-fields').show()
      $("#length_of_stay").show()
      if ( $("#regular").hasClass('active') )
        $("#search_radius").show()
        if ( $("#search_radius input").val() == '' )
          $("#search_radius input").val window.AIDIN.radii.snf_radius
    when window.AIDIN.provider_types.ltac
      $('.ltac-fields').show()
      if ( $("#regular").hasClass('active') )
        $("#search_radius").show()
        if ( $("#search_radius input").val() == '' )
          $("#search_radius input").val window.AIDIN.radii.ltac_radius
    when window.AIDIN.provider_types.pd
      $('.pd-fields').show()
    when window.AIDIN.provider_types.irf
      $('.irf-fields').show()
      if ( $("#regular").hasClass('active') )
        $("#search_radius").show()
        if ( $("#search_radius input").val() == '' )
          $("#search_radius input").val window.AIDIN.radii.irf_radius

  $('#referral_provider_type').live 'change', (e) ->
    $('.provider-fields').hide()
    $('input[type="checkbox"][name*="referral[referral_care_types_attributes]"]').attr("checked", false)
    switch parseInt($('#referral_provider_type').val())
      when window.AIDIN.provider_types.hha
        $('.hha-fields').show()
      when window.AIDIN.provider_types.snf
        $('.snf-fields').show()
        $("#length_of_stay").show()
        if ( $("#regular").hasClass('active') )
          $("#search_radius").show()
          if ( $("#search_radius input").val() == '' ) 
            $("#search_radius input").val window.AIDIN.radii.snf_radius # <----- Here
      when window.AIDIN.provider_types.ltac
        $('.ltac-fields').show()
        if $( ("#regular").hasClass('active') )
          $("#search_radius").show()
          if ( $("#search_radius input").val() == '' )
            $("#search_radius input").val window.AIDIN.radii.ltac_radius # <-------Here
      when window.AIDIN.provider_types.pd
        $('.pd-fields').show()
      when window.AIDIN.provider_types.irf
        $('.irf-fields').show()
        if ( $("#regular").hasClass('active')   )
          $("#search_radius").show()
          if ( $("#search_radius input").val() == '' )
            $("#search_radius input").val window.AIDIN.radii.irf_radius # <---------Here
于 2013-07-24T17:37:36.570 回答