user7152572
user7152572

Reputation: 333

Google location autocomplete not working inside modal

I'm using google autocomplete inside a modal. When I click the input field it display the results behind the modal. I didn't use any css. It work perfect outside the modal. But it is not working fine inside the modal. Please help me.

HTML code

<div class="form-group">
    <p class="control-label1">City</p>
    <input type="text" id="locationTextField" placeholder="" name="city" class="form-control">
</div>

Javascript code

//Google Map
function initialize() {
    var input = document.getElementById('locationTextField');
    var autocomplete = new google.maps.places.Autocomplete(input);
}

function validateCity() {
    searchfield = $('#locationTextField').val();
    if (searchfield == "" || searchfield == null) {
        return false;
    }
    else {
        $('#locationTextField').val('');
        return false;
    }
}
google.maps.event.addDomListener(window, 'load', initialize);

Upvotes: 1

Views: 2504

Answers (1)

user7152572
user7152572

Reputation: 333

I found the answer by adding below code inside css

div.pac-container {
   z-index: 1050 !important;
}

Upvotes: 9

Related Questions