Is there a jQuery plugin that suggests/autocompletes within a textarea?
What I want is to have suggested words or autocompleted text proffered to the user in a textarea like the example image below:
Is there a jQuery plugin that suggests/autocompletes within a textarea?
What I want is to have suggested words or autocompleted text proffered to the user in a textarea like the example image below:
Well there is the autocomplete plugin that does just that, and if you want to pull data from a database I recomment using the ajax API that is included in jQuery.
something like this
$('textarea').keyup(function(){
$.post('ajax/test.php', function(data) {
$('#example').autocomplete(data);
});
});
Also remember this is just the basic structure to give you an idea.
P.S. I just found this it should fill all your needs.
If you reference jQueryUI (same website as jQuery) you can use the following for auto complete: http://jqueryui.com/demos/autocomplete/
It's a simple implementation as well :)
Hope that helps!
This might look like a hack, but you can try imitating to the user that he is typing in the textarea, whereas he would actually be typing in the textinput which is at the position for the next word in a textarea.Once the user selects a suggestion from autocomplete or hits enter or space inside this overlaid textinput, you can remove the text-input with the current word inside the textinput appended to the textarea.
For an autocomplete in text-input you can use on plugin from the plethora of plugins available for jquery.
you can try gcomplete uses the google api for autocomplete anything, with a little modification to the source code, you can change the behavior about the tag input[text]
.
i made changes for the plugin and autocomplete the last word, you can test in github.com/rkmax/gcomplete.
I'm working on: - Autocomplete the current word. - Determine the number of lines (visual) and Textarea the current cursor position to display the list of words right next to the cursor, thanks to SimpleCoder