I have a tagging plugin similar to that of SO.
I use jQuery.ui's autocomplete to power the suggestions.
The user can either manually type in a tagname, or can click it once it shows in the list.
Either way,
When the tag is created it is added to an array that looks like
[{id: 0, name:mytag},{id: 6, name:clickedtag},{id: 0, name:mytag2}]
So its an array of object literals.
If the tag came from the autocomplete I want the ID to be passed through.
else 0.
My question is. How can I pass extra in开发者_如何学Goformation such as an ID through to the autocomplete?
You need to tweak the jquery script for that.
I suggest you this auto-complete in a case where you need to set and pass values to elements other than that is bound to the auto complete.
The code is very easy to modify and the styles are also customized...
You can pass array to the script and the auto-complete works on it as you type.... if you look closely at the below function inside the JS...you will find that the variable 'i' contains the index of the actual word selected.... put your code to set the id after the "for loop" inside the below function is complete...
function actb_penter(){
And in case its not coming inside the function write a code outside it so that you can set value to zero....
This script is having OOP concept so can be used in multiple textboxs
Hope this helps you...good luck...Hailwood
精彩评论