Search
 
SCRIPT & CODE EXAMPLE
 

CSS

pacSelectFirst( submit button

google.maps.event.addDomListener(window, 'load', function() {

  var pac_input = document.getElementById('locatorPlaceSearch');
  var orig_listener;

  (function pacSelectFirst(input) {
    // store the original event binding function
    var _addEventListener = (input.addEventListener) ? input.addEventListener : input.attachEvent;

    function addEventListenerWrapper(type, listener) {
      // Simulate a 'down arrow' keypress on hitting 'return' when no pac suggestion is selected,
      // and then trigger the original listener.
      if (type == "keydown") {
        orig_listener = listener;
        listener = function(event) {
          var suggestion_selected = $(".pac-item-selected").length > 0;

          if (event.which == 13 && !suggestion_selected) {
            var simulated_downarrow = $.Event("keydown", {
              keyCode: 40,
              which: 40
            });
            orig_listener.apply(input, [simulated_downarrow]);
          }

          orig_listener.apply(input, [event]);
        };
      }

      _addEventListener.apply(input, [type, listener]);
      mapsListener = listener;
    }

    input.addEventListener = addEventListenerWrapper;
    input.attachEvent = addEventListenerWrapper;



  })(pac_input);

  autocomplete = new google.maps.places.Autocomplete(pac_input, {
    componentRestrictions: {
      country: $('#hdnLocatorPlace').val()
    },
    types: ['geocode']
  });


  $('#searchAP').off('click').on('click', function(e) {

    var keydown = document.createEvent('HTMLEvents');
    keydown.initEvent("keydown", true, false);
    Object.defineProperty(keydown, 'keyCode', {
      get: function() {
        return 13;
      }
    });
    Object.defineProperty(keydown, 'which', {
      get: function() {
        return 13;
      }
    });
    pac_input.dispatchEvent(keydown);
  });
});
Comment

PREVIOUS NEXT
Code Example
Css :: change height primeng progress spinner 
Css :: css space inter words 
Css :: css cotent tipe 
Css :: capitalize only first letter css 
Css :: CSS Layout - width and max-width 
Css :: accessing folders in css 
Css :: mvc dynamic css 
Css :: css background image is not show change default picture 
Css :: fullpage.js change the color of the anchor 
Css :: code-runner.executormap kotlin 
Css :: mdn css marker 
Css :: how to make a width infinite and hidden using css 
Css :: block property in css 
Css :: twig language name 
Css :: react-responsive modal flashes after closing 
Css :: tailind css cdn 
Css :: adding a background image in css 
Css :: one image on top of other image android kotlin 
Css :: css borrar 
Css :: html overflow scroll only if needed with exemple 
Css :: css check if class as color white 
Css :: oracle apex interactive report odd even 
Css :: cop pics css 
Css :: split group of flex item 
Css :: poretty print css 
Css :: access is denied nul server.js 
Css :: css opposite selector 
Css :: Options for DNSSEC verification of other zones 
Css :: import font woff css 
Css :: customize checkbox 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =