Colin Angevine wrote:
> Hello all,
>
> I'm hoping to use the Ajax.Autocompleter to help users send private
> messages to other users on my site. As the user types in the name of
> another user, Ajax.Autocompleter steps in and offers a few relevant
> options to help them along. Once they find the right one,
> Scriptaculous makes it a breeze for them to select it and enter it
> into the input field.
>
> I'd like to take this one more step, however, and make note of the
> user id (the primary key associated with the name they selected from
> the database) as an invisible field or javascript variable. With this,
> it would be simple to send the private message to the appropriate user
> id. The problem is that since the backend side of Ajax.Autocompleter
> returns an unordered list, I don't know how/ where to store the id
> numbers, or how the form could track that somehow.
There's a couple ways to do this. The auto completer values are an un-ordered
list, but they can have other stuff in there. You are allowed to have a tag of
class "informal" that is displayed, but not used as a value. So do something
like this
<ul>
<li>
<span class="id" style="display:none">1234</span>
<span class="informal">John Doe ([EMAIL PROTECTED])</span>
</li>
</ul>
See http://demo.script.aculo.us/ajax/autocompleter_customized for more details
and an example.
--
Michael Peters
Developer
Plus Three, LP
_______________________________________________
Rails-spinoffs mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs