Logicify / jquery-locationpicker-plugin

JQuery Location Picker plugin
MIT License
389 stars 260 forks source link

Clear on :focus #105

Open yansusanto opened 7 years ago

yansusanto commented 7 years ago

First of all, thank you for creating such an awesome script.

I'd like to know if

  1. it is possible to clear the 'address' field on page load and
  2. assuming there are other input fields to fill, not submitting the form when we accidentally press 'Enter/Return'

What would be the best practice if I'd like to accomplish the above.

Thanks & have a good day.

;)

Sumragen commented 7 years ago

Hi @yanseo! Thank you :)

First: It seems like issue #11; Code example:

$('#map').locationpicker({
   inputBinding: {
      locationNameInput: $('#input-address')
   },
   oninitialized : function (component) {
      $('#input-address').val('');
   }
});

Second: If i have fully understood your issue, that you need initialize another input field and grab just their value, but question consist of 'how i can programmatically autocomplete location' or 'what is correct behavior of program on accidentally press Enter' ?

yansusanto commented 7 years ago

Thanks, Sumragen for your reply.

This doesn't work though, the map disappeared and no autosuggestion ;(

        $('#map').locationpicker({
            inputBinding: {
                locationNameInput: $('#input-address')
            },
            oninitialized : function (component) {
                $('#input-address').val('');
            }
            enableAutocomplete: true,
            onchanged: function (currentLocation, radius, isMarkerDropped) {
            }
        });

Am I missing something here?

PS: This is the working code for me but I need to clear the field first before I could add another address which is of course not so user-friendly

        $('#map').locationpicker({
            location: {
                latitude: 3.139003,
                longitude: 101.68685499999992
            },
            radius: 300,
            inputBinding: {
                latitudeInput: $('#map-latt'),
                longitudeInput: $('#map-long'),
                radiusInput: $('#map-radius'),
                locationNameInput: $('#input-address')
            },
            enableAutocomplete: true,
            onchanged: function (currentLocation, radius, isMarkerDropped) {
            }
        });
jzucadi commented 7 years ago

Anybody have a solution for this?