Skip to content

Commit a9c9a8b

Browse files
author
corvis
committed
Fixed multiple events issue
1 parent 5f967a2 commit a9c9a8b

File tree

6 files changed

+27
-38
lines changed

6 files changed

+27
-38
lines changed

dist/locationpicker.jquery.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! locationpicker.jquery - v0.11.0 - 2015-01-03 */
1+
/*! jquery-locationpicker - v0.11.0 - 2015-01-04 */
22
(function($) {
33
function GMapContext(domElement, options) {
44
var _map = new google.maps.Map(domElement, options);
@@ -132,7 +132,10 @@
132132
function setupInputListenersInput(inputBinding, gmapContext) {
133133
if (inputBinding) {
134134
if (inputBinding.radiusInput) {
135-
inputBinding.radiusInput.on("change", function() {
135+
inputBinding.radiusInput.on("change", function(e) {
136+
if (!e.originalEvent) {
137+
return;
138+
}
136139
gmapContext.radius = $(this).val();
137140
GmUtility.setPosition(gmapContext, gmapContext.location, function(context) {
138141
context.settings.onchanged.apply(gmapContext.domContainer, [ GmUtility.locationFromLatLng(context.location), context.radius, false ]);
@@ -154,14 +157,20 @@
154157
});
155158
}
156159
if (inputBinding.latitudeInput) {
157-
inputBinding.latitudeInput.on("change", function() {
160+
inputBinding.latitudeInput.on("change", function(e) {
161+
if (!e.originalEvent) {
162+
return;
163+
}
158164
GmUtility.setPosition(gmapContext, new google.maps.LatLng($(this).val(), gmapContext.location.lng()), function(context) {
159165
context.settings.onchanged.apply(gmapContext.domContainer, [ GmUtility.locationFromLatLng(context.location), context.radius, false ]);
160166
});
161167
});
162168
}
163169
if (inputBinding.longitudeInput) {
164-
inputBinding.longitudeInput.on("change", function() {
170+
inputBinding.longitudeInput.on("change", function(e) {
171+
if (!e.originalEvent) {
172+
return;
173+
}
165174
GmUtility.setPosition(gmapContext, new google.maps.LatLng(gmapContext.location.lat(), $(this).val()), function(context) {
166175
context.settings.onchanged.apply(gmapContext.domContainer, [ GmUtility.locationFromLatLng(context.location), context.radius, false ]);
167176
});
@@ -250,8 +259,8 @@
250259
updateInputValues(settings.inputBinding, gmapContext);
251260
context.settings.oninitialized($target);
252261
var currentLocation = GmUtility.locationFromLatLng(gmapContext.location);
262+
setupInputListenersInput(settings.inputBinding, gmapContext);
253263
});
254-
setupInputListenersInput(settings.inputBinding, gmapContext);
255264
});
256265
};
257266
$.fn.locationpicker.defaults = {

dist/locationpicker.jquery.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)