javascript - Google location autocomplete not working inside modal - Stack Overflow

I'm using google autoplete inside a modal. When I click the input field it display the results beh

I'm using google autoplete 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 autoplete = new google.maps.places.Autoplete(input);
}

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

I'm using google autoplete 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 autoplete = new google.maps.places.Autoplete(input);
}

function validateCity() {
    searchfield = $('#locationTextField').val();
    if (searchfield == "" || searchfield == null) {
        return false;
    }
    else {
        $('#locationTextField').val('');
        return false;
    }
}
google.maps.event.addDomListener(window, 'load', initialize);
Share Improve this question asked Dec 13, 2016 at 11:47 user7152572user7152572 3331 gold badge4 silver badges16 bronze badges 2
  • can you please provide your html code – RonyLoud Commented Dec 13, 2016 at 11:50
  • @RonyLoud I found the answer. – user7152572 Commented Dec 13, 2016 at 11:55
Add a ment  | 

1 Answer 1

Reset to default 9

I found the answer by adding below code inside css

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744842642a4596650.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信