| Page 1 of 1 | [ 2 posts ] |
|
I am using autocomplete and the multiple-value input module(http://yuilibrary.com/gallery/show/multivalue-input) to build a tagging system for tagging users.
The users are simply key value pairs: Code: { "john" : 1, "david" : 2, } I would like to be able to type a "j" and get a suggestion of "john", and in the select event's object, get access to both "john" and 1. Currently, if I use the object above, I have to type in "john" to get a suggestion of 1, which is not what I need. Is there anyway to do this? |
|
Seems to me like the "key value pairs" concept is a little wonky. I would refactor this by defining an array of objects that looked something like;
Code: [ { fname:"john", userid:1}, {fname:"david", userid: 2}, ... ] Then you can access the search field using AC's " resultTextLocator : 'fname' " setting, see AutoComplete's Locating Results.Your "select" event handler has access to the selected item's original full Object. I worked up a sample at http://jsfiddle.net/blunderalong/Pcjhe/, where I used one of the examples with state names, and created an array of objects. Autocomplete is quite versatile, I suggest you read the user guide and study the examples carefully to learn all of it's capabilities. Todd |
| Page 1 of 1 | [ 2 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group