Yeah, there's a way to limit what the autocompleter returns...
autocomplete :new_tag_name do
post = find_instance
items = Tag.find(:all,:conditions => ['name
LIKE ?',"%#{params[:query]}%"]).select { |i| i.viewable_by?
(current_user) }
items = items - post.tags
render :text => "<ul>\n" +
items.map { |i| "<li>#{i.name}</li>\n" }.join +
"</ul>"
end
Kinda ugly, but should point you in the right direction on how to do
it. This is code from controller btw.
On Feb 23, 1:30 pm, atmorell <[email protected]> wrote:
> select-many is close to what I need, and would work perfectly with
> fewer users. Have been trying to figure out how to solve this problem
> for the last week with no luck. It should be easy to do, but what
> really gives me problems is how to filter out the already selected
> users from the autocomplete ul. I am thinking that the only way of
> doing this might be with javascript client side.
>
> When something is typed into the autocomplete field rails returns a ul
> list. Would it be possibe to filter this query result and removing
> elements that's already in my result div?
>
> http://localhost/users/complete_name?query=j
> <ul>
> <li>jeppe</li> <----- remove this element - it's already in .results
> </ul>
> <ul>
> <li>john</li>
> </ul>
> <ul>
> <li>oscar</li>
> </ul>
>
> <div class="results">
> <ul>
> <li>jeppe</li>
> </ul>
> </div>
>
> On Feb 22, 3:15 pm, Bryan Larsen <[email protected]> wrote:
>
> > It sounds like you want a combination of name-one and select-many. The
> > first question is: have you tried select-many? It's not what you asked
> > for, but it may just be "good enough".
>
> > If you do end up writing a "name-many" tag, this would be a welcome
> > addition to Rapid, and we'd more than happy to assist you in such a task.
>
> > name-one is one of the only tags that requires controller support and is
> > not self-contained in DRYML/Javascript/CSS. If you used scriptaculous'
> > Autocomplete.Local instead of the standard Autocomplete, you might be
> > able to avoid the controller support. Of course, that only works if
> > the number of potential recipients is small enough.
>
> > You shouldn't need a session variable: take a look at the source code
> > to select-many to see now it builds a Hobo compatible array in Javascript.
>
> > Bryan
>
> > atmorell wrote:
> > > Actually I am trying to do this:
>
> > >http://railscasts.com/episodes/74-complex-forms-part-2
>
> > > Any ideas on how to do that with hobo?
>
> > > On Feb 22, 1:25 pm, atmorell <[email protected]> wrote:
> > >> Hello,
>
> > >> I have a form that is used for creating a Message. The Message model
> > >> creates a MessageCopy on save to the recipient(s). What would be the
> > >> best approach to add multiple recipients? (Ajax) I thought about
> > >> creating a temp model for storing the selected recipients, but that
> > >> would give me stalled unused records if the user does not send the
> > >> message. (close browser)
>
> > >> Recipients
> > >> User3 remove-button
> > >> User8 remove-button
>
> > >> Message:
> > >> form
> > >> recipient <--- field with autocomplete.
> > >> subject
> > >> body
>
> > >> I kinda got it working by creating a form that submits the
> > >> autocompleted recipient in a session variable. (Array) It's not pretty
> > >> as I had to build some logic so that the user can't add the same
> > >> recipient twice, self etc.
>
> > >> Any suggestions?
>
> > >> Best regards.
> > >> Asbj rn Morell
>
>
--
You received this message because you are subscribed to the Google Groups "Hobo
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/hobousers?hl=en.