-
-
Notifications
You must be signed in to change notification settings - Fork 109
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
Added replacing feature #27
Conversation
Can you elaborate a bit more on why you would like it to replace the whole input box? |
I see. A lot of people have actually suggested random options for autocomplete given how it is configured right now. I'm trying to control things a bit and avoid feature creep :) However, I see your request as part of a principled way to achieve what was requested in #4. Namely, when doing a single-field autocompletion without the use of symbols, the natural replacement of the text is the whole field. The problem is that the replacement logic doesn't think of spaces as part of the match right now, even though the regexp logic appears to act correctly - otherwise it would replace the right text even without having to have the hacky option of replacing the whole field. My intuition would be to try and fix this function: https://github.com/mizzao/meteor-autocomplete/blob/master/autocomplete-client.coffee#L217, which was basically copy-pasted from jquery-sew. Would you be up for making a simple demo app with the words you are trying to use there, so I can use it to debug this? Basically, just copy some of those documents into a collection and use the same template that you have there now. |
You could use |
I actually don't use the I think the no token replacement should always match the entire field, and so the field always just matches some entry. I don't envision this being a tagging package where multiple things can be selected - that needs to be able to render DOM and can be someone else's job :) Another way you can just fix this is to use the part number instead of those words with spaces, which seem to be not unique and hard to post-process anyway. Or use the callback that someone else sent in a PR. |
Here is a demo app: https://github.com/becorey/meteor-autocomplete-demo |
I've implemented what we discussed and also pulled your demo code into the example app at http://autocomplete.meteor.com/. It's not perfect but it's a big improvement on not supporting this type of behavior before. |
You can specify in the helper if you would like autocomplete to replace only the current word (original behavior), or replace the full input box. I needed this use case and think it would be useful.