-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Dataset API #95
Comments
$el = $('.dropdown-results');
resultsView = new DropdownView($el);
resultsView.populateResults({});
resultsView.refresh();
// or resultsView.render();
results = resultsView.results; //=> [Array of Datum]? What do you think? |
I wouldn't want to add anything to the global namespace. With that in mind, this is sort of what I'm thinking: var dataset = $.typeahead.Dataset({ /* options */ });
dataset.getSuggestions('my query', function(err, suggestions) {
// render suggestions wherever you'd like...
}); |
I was doing something similar earlier today with UI autocomplete (more customizable at the moment, don't blame me). The API looks nice.
What do you think? Best Regards, Adrian Perez Sent with Sparrow (http://www.sparrowmailapp.com/?sig) On Thursday, March 7, 2013 at 1:43 AM, Jake Harding wrote:
|
Sorry I am not familiar with the code base, but could one have Alternatively having datum take another argument, such as |
Just to make sure I'm clear, are you suggesting something like: $('.typeahead').typeahead({
local: function(query) {
// return data
}
}); That could work – I'd have to think about it some more though to make sure it'd fit into how things are currently implemented. |
Yes, exactly. Or a Personally I like a single argument, such as $('.typeahead').typeahead({
computed: function(query) { /* return data */ },
}); or if you are thinking of an asynchronous version (which would be the javascriptish way ☕), $('.typeahead').typeahead({
async_computed: function(query, callback) { /* callback(data) */ },
}); |
From #15 (comment)
|
As is the case where the API allows the download of a sizable data file and that the data needed is already in local storage, my vote would be for query something like this: $('.twitter-typeahead').typeahead('customQuery', 'query goes here', keysToSearch: "values", "customKey1", "tokens", template: customTemplate, function($e) ) {
} |
Hi @jharding, I have an use case that I want to run by you - I want to use 2 (maybe 3) datasets, 1 calling my backend (remote, url with beforeSend), another to call a 3rd party API that is not as simple as remote with an url - for example, Google Places's radarSearch. Would this use case be supported once Dataset API is in? And when would Dataset API be available? Thanks |
You should be able to do that now. Unless I'm missing something, I don't see why you would need the dataset API. |
thanks for quick reply, how do I wire up against Google Places (without dataset API that calls a function similar to Bootstrap typeahead's source). |
I'm not familiar with the Google Places API, but you'll probably want to do something like: $('.typeahead').typeahead({
remote: {
url: 'http://googleplaces.com/search?q=%QUERY',
filter: function(resp) {
// transform response to be typeahead.js compatible
}
}
}); |
unfortunately Google Places doesn't expose a query URL like that.
the query goes into that request. in that callback it returns status and array of results |
Hmm yeah there's not a great way of dealing with that currently. That's a good use case for adding something like If you'd like, create a separate issue for adding |
Got it. I don't know from library design point of view what's the best way to support this, a local with a function, or a distinct source that's similar to Bootstrap typeahead's source. Similar to remote's filter, this use case still needs to format results to make them typeahead.js compatible. I will file a request and reference this. eagerly waiting for this awesome update :) |
I would make sure the query is included since suggestions could come back late and not match the query, e.g.
|
FYI, Google Places does expose a REST API. https://developers.google.com/places/documentation/autocomplete |
@nagiek yes. however Google Places REST API does not allow cross domain calls. It's meant for server side calls. For JavaScript they have a library, which is why we need a function call like |
I plan on working on this during hackweek (July 8-12), potentially with @jasdev if he'd like to pair on it. Voice any ideas, suggestions, or concerns now if you've got a vested interested in using this. |
@timtrueman sure! I'll be OOO on Tues. of that week for DBX but definitely willing to help. |
👍 on this. I'm using the computed function to return actions someone might want to take from the typeahead based on the query, and other datasets for results they will be able to navigate to |
Looking forward to use this, would be really nice to grab a dataset "on the fly"; |
Any update on this issue? It would be really helpful to be able to grab the dataset, so that I can verify that the result chosen by the use is in the suggestion list. |
I'm still waiting on this too. I've since switched back to UI autocomplete
|
So i have two sort of hacky solutions for this:
|
Changes for packaging up v1.0.0
We should expose an API for getting suggestions programmatically. Need to put some thought into what this API would look like exactly.
The text was updated successfully, but these errors were encountered: