Actually it is really simple. You need to have the jQueryUI
autocomplete library in your applications js folder (webroot/js),
without that, it won't work. In the view you only need a few lines of
code like:

$this->Js->buffer(
 '$("ID_OF_THE_AUTOCOMPLETE_INPUT").autocomplete({
  source: "/CONTROLLER/AUTOCOMPLETE_ACTION",
 });
);

Implement an action that does fetch the data for autocomplete in your
controller do:
1. check that the request isAjax()
2. fetch the data your want in your autocomplete field.
3. set the data for the view (in my case I made an extra view since
the jQuery-Autocompleter expects JSON-encoded data.
4. in the view, do an $this->Js->object(DATA_TO_ENCODE); so the data
is as expected.

That's it.

On 11 Apr., 05:21, tubiz <tayi...@gmail.com> wrote:
> Please I have been trying to implement the AJAX autocomplete found in
> the Cakephp 1.3 cookbook but I havent gotten it to work.
>
> There is a artist table in my database and I would like to implement
> autocomplete for a field in the Submit action in the Lyrics controller
>
> The autocomplete will be getting the name of artist in the artist
> controller and displaying it in a text field in the Lyrics controller.
>
> Would like to know how to do this and would the autocomplete action be
> in the artist controller or in the lyrics controller.
>
> Thanks.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to