Monday, February 23, 2009

Re: Autocomplete search on users table

My first disclaimer is that I dont use jQuery nearly as much as I want to.
I tend towards prototype. However..

http://docs.jquery.com/Plugins/Autocomplete
This looks like a pretty good Autocomplete plugin for jQuery.

It just wants an array of data that it is supposed to match to.
Not sure how this works in searching all your data, and matching to a user.
But as a starting point, you could return names to begin with:

// Controller Code
$names = implode('|', Set::extract('/MyModel/name',
$this->MyModel->find('all', array('conditions' => array( ... )))));
$this->set(compact('names'));


// Javascript code
var names = "<?php echo $names; ?>";
$("#my_input").autocomplete(names.split('|'));

Of course, the cooler, more hip options are to postback after observing a
change on the input, and AJAX/JSON look for data, only returning back
strings containing the information you have partially entered. This could
potentially be more powerful, allowing you to pass back more information
like ID's to link to, as well as doing SQL "WHERE LIKE" matches, for
mid-string matching.

Hope this gets you started.

Cheers,

Graham Weldon
w. http://grahamweldon.com
e. graham@grahamweldon.com
p. +61 407 017 293


On Mon, 23 Feb 2009 19:59:02 -0800 (PST), Mike <mickael.henry@gmail.com>
wrote:
> Hi everyone,
>
> I'd like to know if there is out there a component or helper using
> JQuery to help me build a search autocomplete functionnality on a
> users table.
>
> I'd like the end user to be able to search a user by firstname,
> lastname, email and phone number, everything using an autocomplete
> text field.
>
> Any help or start point ?
>
> Thx
>
--

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: