Is there a way to pass in a parameter (e.g. an ID) to the auto_complete_for... method? I have a table of answers that I''m serving up for auto-completion, but I only want the answers that apply to a given field. In my answers table, each entry has an list ID, and I would like to be able to to just get the answers that match the ID for a particular list. I''ve overridden the auto_complete_for.... for method to specify my own :conditions parameter, but so far I''m hard-coding the answer list ID. What I''d really like to do is, perhaps in the rhtml, specify an ID parameter that then somehow the auto_complete_for... would be able to access. Is there a way to do that? Thanks, --Paul --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I found a solution, which I will share for the other newbies out
there. It turns out that you can specify an :id parameter for the URL
you are accessing for the autocompletion by doing this in your view:
<%= text_field_with_auto_complete :answer, :answer_text, {},
{url=>{:action=>''auto_complete_for_answer_answer_text'',
:id=>23} }%>
Here the :action is set to my auto_complete_for method, and the id is
the ID of the list whose options I want to use for auto-completion.
In my controller, the auto_complete_for_answer_answer_text can access
the ID as params[:id].
--Paul
On Mar 13, 2:38 pm, "Paul Lynch"
<plynch...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Is there a way to pass in a parameter (e.g. an ID) to the
> auto_complete_for... method? I have a table of answers that I''m
> serving up for auto-completion, but I only want the answers that apply
> to a given field. In my answers table, each entry has an list ID, and
> I would like to be able to to just get the answers that match the ID
> for a particular list.
>
> I''ve overridden the auto_complete_for.... for method to specify my
> own :conditions parameter, but so far I''m hard-coding the answer
list
> ID. What I''d really like to do is, perhaps in the rhtml, specify
an
> ID parameter that then somehow the auto_complete_for... would be able
> to access. Is there a way to do that?
>
> Thanks,
> --Paul
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Hi
I am using Ajax.Updater and I am having a bit of a
problem with Prototype. I am trying to use a sortable
list (from scriptaculous) and so I want using ajax do
some server logic.
Problem is that the list never show the correct array
on the server side. So I looked at the javascript (you
can see the code lower that works...)
When I look at the Sortable.serialize(''list''); it show
correctly list[]=1&list[]=4&list[]=3
So I would expect the ajax request to look as a get
myurl/?list[]=1&list[]=4&list[]=3
but instead show a weird querystring
myurl/?list%5B%5D=3&_
So looks like when the param are serialized in the
Ajax object itself is screwed up. I have a work around
but wonder if someone else had the same problem.. Also
the dev.rubyonrails.com is down so I cannot post/look
up bugs
following is my javascript code that works but I had
to set the parameters to false and append my
querystring to the URL to fix it.....
<script type="text/javascript">
// <![CDATA[
Sortable.create(''list'', {onUpdate:function(){
var params = Sortable.serialize(''list'');
//BUG in prototype. Element with name [] do no get
serialized correctly...
new Ajax.Updater(''list-info'', ''<%= path
%>'' + ''?''
+ params, {
method: ''get'',
onComplete:function(request){
new Effect.Highlight(''list'',{});
}, parameters: false
, evalScripts:false, asynchronous:true
}
)
}
}
)
// ]]>
</script>
Emmanuel
____________________________________________________________________________________
Finding fabulous fares is fun.
Let Yahoo! FareChase search your favorite travel sites to find flight and hotel
bargains.
http://farechase.yahoo.com/promo-generic-14795097
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---