Since the pac-container is inserted dynamically, you have to listen for it to be inserted. Since you're using jQuery, here's a solution:
$(document).bind('DOMNodeInserted', function(e) {
// Ignore dynamically-inserted scripts and other elements
// since .pac-container is a div
if (e.target.nodeName === 'DIV') {
// Prioritizes the contained functions
setTimeout(function() {
var $el = $(e.target);
if ($el.attr('class') === 'pac-container pac-logo') {
self.cleanAutocomplete($el);
}
}, 0);
}
});
// Remove bound events on document for performance
// and move .pac-container
function cleanAutocomplete($el) {
$(document).unbind('DOMNodeInserted');
$el.detach().insertBefore($('.row'));
};
I was trying to solve the same problem and this works for me. I'm using Backbone, so the $(document).bind(...) is contained within the function that's creating the autocomplete with new google.maps.places.Autocomplete(...).
The main thing to watch out for here is that you'll probably have multiple instances of .row so you should probably give it a unique class or ID.
Hope that helps!