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

easyautocomplete dropdown list doesnt get populated #416

Closed
supmanyu opened this issue Nov 9, 2019 · 0 comments
Closed

easyautocomplete dropdown list doesnt get populated #416

supmanyu opened this issue Nov 9, 2019 · 0 comments

Comments

@supmanyu
Copy link

supmanyu commented Nov 9, 2019

I'm trying to use a geocoding API with eac to create a location input with suggestions.
The JSON data returned by the restAPI is formatted like this:

    [
      {
        "language": "en",
        "countryCode": "AUS",
        "matchLevel": "city",
        "label": "Australia, SA, 5000, Adelaide",
        "locationId": "NT_yL.zQ27bg8PDwwq8gKr8wA",
        "address": {
          "postalCode": "5000",
          "country": "Australia",
          "state": "SA",
          "city": "Adelaide"
        }
      }
    ]

My eac options are set like this:

$( document ).ready(function() {
	var options = {
		url: function(phrase) {
            return "/url_to_api";
        },
    getValue: function(data){
        return data.label;
    },
    listLocation: function(data) {
            console.log(data);
            return data[0];
        },
    noResults: "No Results",
        ajaxSettings:{
            dataType: "json",
            method: "GET",
            data:{
                dataType: "json"
            },
            success: function(json){},
            error: function(xhr, errmsg, err){
                toastr.warning("Unable to fetch search suggestion data from URL. Please make sure that you are connected to the internet. " + xhr.status);
            }
        },
        preparePostData: function(data) {
            data.phrase = $("#camp_loc").val();
            console.log(data.phrase);
            return data;
        },
    list: {
      match: {
        enabled: true,
      },
      hideAnimation: {
        type: "slide",
        time: 400,
      },
    },
        adjustWidth: false,
        requestDelay: 10,     
	};
  $("#camp_loc").easyAutocomplete(options);
});

The data is received successfully, However the eayautocomplete dropdown is not showing up below the input box, which can be seen in the screenshot below.
Screenshot from 2019-11-09 12-25-46

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

No branches or pull requests

1 participant