populateCitiesDropdown( e ) {
    let provCode = $( e.currentTarget ).val() || '0';
    let $wrapper = $( e.currentTarget ).closest( '.woocommerce-billing-fields, .woocommerce-shipping-fields' );

    // if not first run, empty out the city field
    if( !this.isFirstRun ) {
      let $ogCityField = $wrapper.find( '#billing_city_field, #shipping_city_field' );
      $ogCityField.find( 'input' ).val( '' );
    }

    // add 'Loading' message to existing field
    let $citiesSelect = $wrapper.find( '#_billing_city_field select, #_shipping_city_field select' );  
    $citiesSelect.html( '<option>Loading...</option>' );

    // Add notice message to districts field
    let $districtsSelect = $wrapper.find( '#_billing_district_field select, #_shipping_district_field select' );  
    $districtsSelect.html( '<option>Pilih Kota terlebih dahulu...</option>' );


    wcisAPI.get( wcisLocalize.WCIS_API + '/cities/' + provCode )
      .then( result => {
        let options = '';
        for( let id in result ) {
          options += `<option value="${id}">${result[id]}</option>`;
        }

        $citiesSelect.html( options );
      });

    this.isFirstRun = false;
  }
/**
   * Populate the City dropdown according to selected State
   * 
   * TODO: change to pure JS
   */
Populate the City dropdown according to selected State

change to pure JS
Populate the City dropdown according to selected State change to pure JS
populateCitiesDropdown( e ) {
    let provCode = $( e.currentTarget ).val() || '0';
    let $wrapper = $( e.currentTarget ).closest( '.woocommerce-billing-fields, .woocommerce-shipping-fields' );
    if( !this.isFirstRun ) {
      let $ogCityField = $wrapper.find( '#billing_city_field, #shipping_city_field' );
      $ogCityField.find( 'input' ).val( '' );
    }
    let $citiesSelect = $wrapper.find( '#_billing_city_field select, #_shipping_city_field select' );  
    $citiesSelect.html( '<option>Loading...</option>' );
    let $districtsSelect = $wrapper.find( '#_billing_district_field select, #_shipping_district_field select' );  
    $districtsSelect.html( '<option>Pilih Kota terlebih dahulu...</option>' );
    wcisAPI.get( wcisLocalize.WCIS_API + '/cities/' + provCode )
      .then( result => {
        let options = '';
        for( let id in result ) {
          options += `<option value="${id}">${result[id]}</option>`;
        }
        $citiesSelect.html( options );
      });
    this.isFirstRun = false;
  }
populateCitiesDropdown ( e ) { let provCode = $ ( e . currentTarget ) . val ( ) || '0' ; let $wrapper = $ ( e . currentTarget ) . closest ( '.woocommerce-billing-fields, .woocommerce-shipping-fields' ) ; if ( ! this . isFirstRun ) { let $ogCityField = $wrapper . find ( '#billing_city_field, #shipping_city_field' ) ; $ogCityField . find ( 'input' ) . val ( '' ) ; } let $citiesSelect = $wrapper . find ( '#_billing_city_field select, #_shipping_city_field select' ) ; $citiesSelect . html ( '<option>Loading...</option>' ) ; let $districtsSelect = $wrapper . find ( '#_billing_district_field select, #_shipping_district_field select' ) ; $districtsSelect . html ( '<option>Pilih Kota terlebih dahulu...</option>' ) ; wcisAPI . get ( wcisLocalize . WCIS_API + '/cities/' + provCode ) . then ( result => { let options = '' ; for ( let id in result ) { options += ` ${ id } ${ result [ id ] } ` ; } $citiesSelect . html ( options ) ; } ) ; this . isFirstRun = false ; }
Populate the City dropdown according to selected State
Populate the City dropdown according to selected State
// if not first run, empty out the city field // add 'Loading' message to existing field // Add notice message to districts field