admin管理员组文章数量:1022989
I am wanting to trigger my placed_changed
function when a submit button is clicked. So here is what I have, I have a searchbox
I assign using google.maps.places.SearchBox
and once I click enter with the search box on focus it triggers the event:
google.maps.event.addListener(searchBox, 'places_changed', function() {
runMainPopulation(searchBox.getPlaces());
});
Which runs the next function. Now what I am trying to do is get this function to run once I click a search button
or I click enter on my searchbox
.
Suggestions, thoughts?
I am wanting to trigger my placed_changed
function when a submit button is clicked. So here is what I have, I have a searchbox
I assign using google.maps.places.SearchBox
and once I click enter with the search box on focus it triggers the event:
google.maps.event.addListener(searchBox, 'places_changed', function() {
runMainPopulation(searchBox.getPlaces());
});
Which runs the next function. Now what I am trying to do is get this function to run once I click a search button
or I click enter on my searchbox
.
Suggestions, thoughts?
Share Improve this question asked Jan 7, 2015 at 22:27 David BigaDavid Biga 2,8118 gold badges41 silver badges63 bronze badges 2-
Does
google.maps.event.trigger(searchBox,'places_changed')
not work? – geocodezip Commented Jan 7, 2015 at 22:38 - @geocodezip No it does not – David Biga Commented Jan 7, 2015 at 22:41
1 Answer
Reset to default 5I figured it out.
I had to initialize the Google searchBox
via google method
post.
For instance:
$(".submit-search").bind('click', function() {
input.focus();
var e = jQuery.Event("keydown");
e.which = 13; // # Some key code value
$(input).trigger(e);
google.maps.event.trigger(searchBox, 'place_changed');
});
This would not work, I am not to sure as to why but it doesn't. submit-search
is the button next to searchBox
also defined as input
.
Now if I initialize my input trigger focus and click through google.maps.event.trigger
it works perfect:
$(".submit-search").bind('click', function() {
google.maps.event.trigger(input, 'focus')
google.maps.event.trigger(input, 'keydown', {
keyCode: 13
});
});
I am wanting to trigger my placed_changed
function when a submit button is clicked. So here is what I have, I have a searchbox
I assign using google.maps.places.SearchBox
and once I click enter with the search box on focus it triggers the event:
google.maps.event.addListener(searchBox, 'places_changed', function() {
runMainPopulation(searchBox.getPlaces());
});
Which runs the next function. Now what I am trying to do is get this function to run once I click a search button
or I click enter on my searchbox
.
Suggestions, thoughts?
I am wanting to trigger my placed_changed
function when a submit button is clicked. So here is what I have, I have a searchbox
I assign using google.maps.places.SearchBox
and once I click enter with the search box on focus it triggers the event:
google.maps.event.addListener(searchBox, 'places_changed', function() {
runMainPopulation(searchBox.getPlaces());
});
Which runs the next function. Now what I am trying to do is get this function to run once I click a search button
or I click enter on my searchbox
.
Suggestions, thoughts?
Share Improve this question asked Jan 7, 2015 at 22:27 David BigaDavid Biga 2,8118 gold badges41 silver badges63 bronze badges 2-
Does
google.maps.event.trigger(searchBox,'places_changed')
not work? – geocodezip Commented Jan 7, 2015 at 22:38 - @geocodezip No it does not – David Biga Commented Jan 7, 2015 at 22:41
1 Answer
Reset to default 5I figured it out.
I had to initialize the Google searchBox
via google method
post.
For instance:
$(".submit-search").bind('click', function() {
input.focus();
var e = jQuery.Event("keydown");
e.which = 13; // # Some key code value
$(input).trigger(e);
google.maps.event.trigger(searchBox, 'place_changed');
});
This would not work, I am not to sure as to why but it doesn't. submit-search
is the button next to searchBox
also defined as input
.
Now if I initialize my input trigger focus and click through google.maps.event.trigger
it works perfect:
$(".submit-search").bind('click', function() {
google.maps.event.trigger(input, 'focus')
google.maps.event.trigger(input, 'keydown', {
keyCode: 13
});
});
本文标签: javascriptTrigger placeschanged in Google maps from submit buttonStack Overflow
版权声明:本文标题:javascript - Trigger places_changed in Google maps from submit button - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745579596a2157230.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论