I took a look at the example on the Scriptaculous site and I'm still a
bit unclear. I'm already using the informal class, and it makes good
sense to use it again (with a display:none there) but I'm not sure how
I'll be able to retrieve that id number once the user selects it. Just
a bit more context around how you approached it (or maybe a peek at
the code you put together) would be wonderful.

Thanks,
Colin

On 8/14/06, Michael Peters <[EMAIL PROTECTED]> wrote:


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
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to