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

Provide working example of remote source in documentation #97

Open
c256985 opened this issue Nov 6, 2017 · 4 comments
Open

Provide working example of remote source in documentation #97

c256985 opened this issue Nov 6, 2017 · 4 comments

Comments

@c256985
Copy link

c256985 commented Nov 6, 2017

I can't seem to figure out how the remote source functionality is supposed to work. My thought is that if you supply a json file or REST endpoint, along with a text and property value, then it should extract these attributes from the response, and add them as suggestions to the autocomplete list.

<paper-autocomplete label="Users" autofocus remote-source source="/data/userlist.json" text-property="name" value-property="id">

Where the json file looks something like this:

[ {"id": 1, "name":"John Smith"}, {"id":2, "name":"Jane Doe"}]

But this doesn't seem to work. Am I missing something?

@leifneve
Copy link

The source property is ignored if remote-source is used. The documentation says to listen to changes using the change event and provide suggestions using the suggestions() method. That is working for me.

@MrMcGibblets
Copy link

Considering I just found @leifneve comment extremely useful as I was confused with the documentation, I would recommend either an example or just a little paragraph.

@jhuesos
Copy link
Collaborator

jhuesos commented Mar 21, 2018

Agree, I am not very happy with the remote-source implementation, I think it is kind of confusing. I will try to add the example in the documentation.

Whenever I have time, my plan is to re-write the component to be only Polymer 2 compatible, to make it faster. My idea is to simplify it and change the way remote-source works. One of the ideas I have is to remove the remote-source option and just change queryFn to accept functions that returns promises. When queryFn returns promises it is assumed that it is a remote-search and the component will work just fine.

But once I find the time to start with new implementation, I will open an issue to collect feedback.

@ndormont
Copy link

queryFn + Promise is definitely the way to go! great idea.

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

5 participants