Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support "auto" as a default country with geoIP lookup #6

Open
mrmarkfrench opened this issue Jul 29, 2015 · 5 comments
Open

Support "auto" as a default country with geoIP lookup #6

mrmarkfrench opened this issue Jul 29, 2015 · 5 comments
Assignees

Comments

@mrmarkfrench
Copy link
Owner

The International Telephone Input plugin that this one is based on supports a defaultCountry option of "auto", which prompts it to perform a geoIP lookup on the client browser and select the current country as the default.

This also necessitates the addition of a geoIpLookup parameter, which provides a function to actually perform the lookup. The assumption here is that a geo-location plugin is already installed (or will be installed to supply this feature), and an appropriate function to invoke it is easy to supply.

This requires both supporting this feature in the first place, and also providing enough information in the documentation to allow users to supply their own lookup function.

@mrmarkfrench
Copy link
Owner Author

Note that this enhancement request was added in response to #5, which was a bug about the failure that results if you attempt to use this feature (which the documentation at the time claimed was already implemented). The fix to #5 resolved the error, and corrected the documentation, and was thus closed.

Adding the feature as part of the fix to #5 was out of scope, but clearly the feature would be helpful and should be supported.

@themohitmadan
Copy link

+1

@themohitmadan
Copy link

Tried fixing it:

<script> var defaultSelect = ''; var countryViaIp = ''; $.ajax({ url: "https://geoip-db.com/jsonp", jsonpCallback: "callback", dataType: "jsonp", success: function( location ) { defaultSelect = location.country_code; countryViaIp = defaultSelect.toLowerCase(); $("#country").countrySelect({ defaultCountry: countryViaIp, preferredCountries: ['ca', 'gb', 'us'], responsiveDropdown: true }); } }); </script>

@iamkarsoft
Copy link

@mrmarkfrench Has this been added to the plugin if yes? how do I get the country by ip

@mrmarkfrench
Copy link
Owner Author

@iamkarsoft No directly, no, but the snippet above demonstrates a way that you can gain access to the functionality external to the plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants