Zendcasts Forum

A community of developers who work with the Zend Framework and other enterprise PHP technologies

You are not logged in.

#1 2010-07-26 10:33:18

Jon Lebensold
Administrator
Registered: 2009-06-27
Posts: 279

ZC59 – Autocomplete Control with ZendX_JQuery

In the last video, I discussed ZendX_JQuery integration. Now we're going to take it a step further by developing our own jQuery autocomplete control, using a country list, PHP 5.3 and anonymous functions.

Offline

#2 2010-08-10 07:31:16

Xavier
Member
Registered: 2010-08-10
Posts: 13

Re: ZC59 – Autocomplete Control with ZendX_JQuery

Hey Jon,

First I want to thank you for the good work, nice videos and stuff.
I've tried the video based with some extras like db connection and form controller, but i have an issue ginving extraParams.

I want people to select a user and return the ID value and not the name  of this user.

Did you experience this already?

thx,

Xavier

Offline

#3 2010-08-10 08:17:58

Jon Lebensold
Administrator
Registered: 2009-06-27
Posts: 279

Re: ZC59 – Autocomplete Control with ZendX_JQuery

Hi Xavier,

In order to get this sort of thing to work, you'll have to probably pass back more than just a list of usernames. I'm not sure how much flexibility the autocomplete control has in this regard, but you would want to send back a small json structure for each result.

e.g.
[{"user" : "Jon" , "id" : 23}, {"user": "Xavier" , "id" :24}, ...]

once you have it in this format coming from the server, you could then parse it on the client so that the username is all that shows up and you could store the id either in the DOM or in a variable on the page.

Hope that helps,
-
Jon

Offline

#4 2010-08-14 14:12:50

Xavier
Member
Registered: 2010-08-10
Posts: 13

Re: ZC59 – Autocomplete Control with ZendX_JQuery

hi,

I tried an tried, but nothing seems to work out ...

JQuery wants something like :["User1","User2","User3"]

Someone already figured outs a problem like this?

I want to replace a dropdown, but it needs to do the trick offcourse ...

Offline

#5 2010-08-14 19:44:03

iiTyr
Member
Registered: 2010-03-27
Posts: 13

Re: ZC59 – Autocomplete Control with ZendX_JQuery

Dump your code snippet...

Offline

#6 2010-08-14 20:00:40

Xavier
Member
Registered: 2010-08-10
Posts: 13

Re: ZC59 – Autocomplete Control with ZendX_JQuery

Hey,

found a prefect solution for me.

Instead of pretending the combobox, overwrite him ...

found the code here and i works like a charm!

http://jqueryui.com/demos/autocomplete/#combobox

thx for the feedback guys

Offline

#7 2010-08-16 08:23:00

Jon Lebensold
Administrator
Registered: 2009-06-27
Posts: 279

Re: ZC59 – Autocomplete Control with ZendX_JQuery

Thanks for sharing Xavier smile

Offline

#8 2010-09-14 21:34:03

ZBI
New member
Registered: 2010-09-14
Posts: 1

Re: ZC59 – Autocomplete Control with ZendX_JQuery

Hi,

first: thx for this great tutorial.

I tried to extend this autocomplete form with typical usages, similar to Xaviars needs.

These functionalities are nearly in every autocomplete search form of my applications:

1. Search over multiple tables and columns to get the nessessary data.
2. Return more than one Information out of one column to identify the selection data. (e.g. if you search a name, display the firstname, name and zip code)
3. Add some action if we focus a entry
4. Add some action if we select a entry (fill hidden fields or do some more ajax requests)

I am trying to get this work with zendx since five days. Sure with nearly 3 days of googling wink

You can follow my steps, thoughts an results in this thread:
http://www.zfforums.com/zend-framework- … -5510.html

I hope we can find a nice solution together, because I think this is the most wanted functionality of autocomplete or extended search fields.

Thx for helping. May be this is a stuff for the next tutorial wink

Offline

Board footer

Powered by FluxBB