Hello all,
I''m integrating the autocompleter widget with a Java backend.
This technical part was a piece of cake, but not the CSS design of the
widget value list.
The page, http://demo.script.aculo.us/ajax/autocompleter_customized ,
shows Ruby On Rails code :
# _contacts.rhtml partial
<ul class="contacts">
<% for contact in @contacts do -%>
<li class="contact">
<div class="image">
<img src="/demos/images/contacts/<%= contact.id.to_s[-1,1]
%>.jpg"/>
</div>
<div class="name"><%=h contact.name %></div>
<div class="email">
<span class="informal"><%=h contact.email
%></span>
</div>
</li>
<% end -%>
</ul>
This code permits to show styled values and this is what I tried to do
without success.
I do not understand how to add this specifc html in the Autocompleter.
Currently, I have :
<script type="text/javascript">
new Autocompleter.Local(''mnemo'',
''mnemo_list'', resultArray, options );
</script>
resultArray is a Javascript array containing all the values (the
contacts in the Ruby example).
Should I append for each contact the <li>...</li> html piece of code
?
But where do I add the surrounding <ul
class="contacts">...</ul> ?
Thanks a lot,
Tom
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs
-~----------~----~----~----~------~----~------~--~---
Hello Tom, First: Autocompleter.Local is LOCAL, not Ajaxified. So it doesn''t integrate with a back-end, unless you back-end preloads all data in the page, which is inefficient on large datasets. Autocompleter.Local builds its own HTML, without any extras beyond ul/li and <strong>-highlited matching portions. Your stylesheet can work on rules such as #mnemo_list ul and #mnemo_list li, since you have your container element around this list. If you need to provide more than simple <li> elements (e.g. "informal" blocks, images, etc.) you need to either: 1) write your own selector callback function (which takes the Autocompleter.Local object as an argument, on whose options property you can iterate). This method is responsible for the whole search/completion/filtering/formatting behavior, which is a hassle. OR 2) use Ajax.Autocompleter, and build the XHTML ul/li fragment on the server side, as per the Ruby example you quote from the Wiki. You''re then responsible for the code creation *server-side*, which is way more efficient for large datasets. You would then bind to a specific servlet of yours, which would create the XHTML fragment based on the passed parameter(s). Look into the "parameters" and "defaultParams" options, and into the "callback", er... callback :-) This thing is *way* customizable (I wrote a JS subclass that applied an XSLT transform over an XML result to produce the desired ul/li structure, so there''s no limit to how you can tweak it!). ''HTH -- Christophe Porteneuve aka TDD tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
Thanks for your complete reply. It was very clear. I will try the Ajax autocompleter as written in the ruby sample. Again, thanks a lot, Tom --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---