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

which dataset did the selected item come from #203

Closed
visualjazz-dporter opened this issue Apr 18, 2013 · 6 comments
Closed

which dataset did the selected item come from #203

visualjazz-dporter opened this issue Apr 18, 2013 · 6 comments

Comments

@visualjazz-dporter
Copy link

Ability to know which dataset a selected or autocompleted item came from

@jeffmax
Copy link
Contributor

jeffmax commented Apr 18, 2013

I was just looking for the same information. It appears the datum returned is actually the object held in the internal itemHash on each dataset, so you can find it by search and comparing the object references, but this would be nice to have.

@visualjazz-dporter
Copy link
Author

Hi @jeffmax thanks for your response, were you able to do this? If possible can you give me an example of how to implement it?

@jeffmax
Copy link
Contributor

jeffmax commented Apr 19, 2013

@visualjazz-dporter, I failed to mention that this will only work for datums that were from a "local" source. In that case, you can call .data() on the typeahead jQuery object and look in the ttView.datasets object. This will contain a list of objects, each containing a itemHash attribute containing all the datums for that datasource. You can compare the datum handed to you against this. This is not a great solution since it could easily break and doesn't work for remote datums. I am working on a pull request that would pass the datasource the datum was from to the listen handler. It is relatively simple, but I don't know if it would be accepted. I am not quite done, but you can see it at work here.

http://jsfiddle.net/qWmf2/18/

I'll update this later when I have had more time to look at the ramifications of the changes I made.

@visualjazz-dporter
Copy link
Author

@jeffmax I like your work - yeah looking to use it on a remote source. I hope this gets the tick of approval. Thanks.

@dannyc
Copy link

dannyc commented Apr 21, 2013

Seems like similar issue as #196 There @jharding suggested using namespaced events to accomplish a similar result. Your idea seems more direct in terms of uniformly handling the data and using the dataset name as added information, whereas namespaced events is more elegant from the event listener perspective, since you can avoid using if's. But I guess is comes down to what is the more common use-case.

@jharding
Copy link
Contributor

I'm going to close this in favor of #196.

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

No branches or pull requests

4 participants