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

Best way to handle updating the options and removing the autocomplete #30

Open
adamjudd opened this issue Jan 6, 2012 · 10 comments
Open

Comments

@adamjudd
Copy link

adamjudd commented Jan 6, 2012

Hey guys,

I have two quick questions:

What would be the best way to update the options used in the autocomplete? This can be easily achieved by running extract_options() again, but how can this be run at any time by the user and still have access to context?

Similarly, should a function be incorporated to destroy the selectToComplete functionality?

@drbroad
Copy link

drbroad commented Jan 23, 2012

i second that.

it would be nice if there were methods similar to (unless im missing something obvious) to update()/disable()/destroy()

@fosskers
Copy link

fosskers commented Dec 6, 2014

Is there still no way to do this? It still seems to be a problem. I'm looking into using jquery-ui natively.

EDIT: This is probably a good native alternative.

@dmasterman
Copy link

Can you tell me why all of your blog email is coming to me? It is annoying! Please remove me from your mail list!!!!
Dave Masterman
[email protected]

On Dec 6, 2014, at 3:11 PM, Colin Woodbury [email protected] wrote:

Is there still no way to do this? It still seems to be a problem.


Reply to this email directly or view it on GitHub #30 (comment).

@ajquick
Copy link
Contributor

ajquick commented Dec 11, 2014

This extension uses the Jquery UI autocomplete function. It just needs some extra work to extend out the update, create, disable, destroy... etc. methods.

Anyone willing to do it?

@fosskers
Copy link

To whatever wayward soul may wander here in future: don't use this library.

Anything you want to do with this can be done just as easily with the native jQueryUI widget autocomplete. Here:

Creating

$("#foo").autocomplete({ source: [ ... options here ... ] });

Reacting to a selection

$("#foo").on("autocompleteselect", function(event, ui) {
    var selectedOption = ui.item["value"];

    // Do something based on the selection.
    $.ajax({ ... whatever ... });

Updating

var newOptions = [ ... whatever ... ]  // Maybe you got these from an AJAX call?
var foo = $("#foo");

foo.autocomplete("destroy");
foo.autocomplete({ source: newOptions });

Go forth, and may your Forms be beautiful.

@ajquick
Copy link
Contributor

ajquick commented Dec 24, 2014

fosskers. While I'm pretty sure this library extends jQuery UI's Autocomplete, I am pretty much on board with you at this point. I can't figure out how to do simple updates, selects, triggers etc. I was just thinking about converting back to UI's autocomplete.

The only question I have is can UI's autocomplete do the whole alternative spelling and weighted selection? I'd love if someone could type in "US" and have it select "United States" for example.

I've been running down bugs in my project for days, and they are all related to getting this library to work.

@fosskers
Copy link

Unfortunately alternate spellings, etc, is where this library shines. The native autocomplete doesn't have an equivalent, but you might be able to hack something together with this.

@ajquick
Copy link
Contributor

ajquick commented Dec 24, 2014

Thanks for you help. Here is my working example with alternative spelling:

http://jsfiddle.net/1j01zk8z/

I choose to display the label to the user, and then submit the value in a hidden field. This method will match the label, value or alternative spelling. It will also prevent from a user entering an invalid choice. I might even add the relevancy booster as well, but I'm not sure about that one yet.

Now all my problems will be solved!

@craigcosmo
Copy link

@ajquick your working example is not working.

Any updates for this topic. The update function is important and it's missing...

@fosskers
Copy link

@craigcosmo Just use the native jQuery widget, this library isn't really maintained.

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

6 participants