Note that there are some explanatory texts on larger screens.

plurals
  1. POautocomplete of words in the middle (jQuery UI)
    primarykey
    data
    text
    <p>Anyone know good sample code using jQuery UI's autocomplete widget that can autocomplete words in the middle of a text box, not just autocomplete of the word at the end only? </p> <p>I'm using the jquery UI autocomplete widget for a component that supports entry of multiple tags. It's like like stack overflow's tag editor, but simpler: no fancy formatting in the autocomplete dropdown, no "tag" background images in the edit box. I started with the <a href="http://jqueryui.com/demos/autocomplete/#multiple" rel="nofollow noreferrer">jQuery UI Autocomplete Multiple sample</a> and modified it. </p> <p>It's working OK, except autocomplete doesn't work for tags in the middle of a multi-tag string. For example, if I type <code>C Fortran</code> and then put the caret right after <code>C</code> and type <code>+</code>, I'd expect to see <code>C++</code> in the autocomplete list but instead I see <code>Fortran</code> again. </p> <p>Here's the code so far: <a href="http://jsfiddle.net/WCfyB/4/" rel="nofollow noreferrer">http://jsfiddle.net/WCfyB/4/</a></p> <p>This is the same problem described by <a href="https://stackoverflow.com/questions/7089406/autocomplete-in-middle-of-text-like-google-plus">autocomplete in middle of text (like Google Plus)</a>, but the problem in that question was simpler because he could rely on an empty <code>@</code> in the text to signal when to show the autocomplete. In my case, I can't just rely on the text-- I actually need to find out where the caret is and autocomplete for the word where the caret is. </p> <p>I could build this myself using caret or another plugin, but was wondering if there was already a jQuery-UI-based sample online that I could use without re-inventing another wheel, especially if there are browser-specific corner cases to worry about. Ideally, it'd behave like this: whenever the user places the caret inside or at the end of a tag (where tags are always separated by 1+ spaces), autocomplete is shown for that tag. Know a good sample?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload