[Seaside] JQuery ui autocomplete with multiple parameters

Robert Sirois watchlala at hotmail.com
Mon Aug 27 14:50:31 UTC 2012


I don't know that autocomplete has any functionality for filtering. Perhaps there's a third party modification that accomplishes that; however, it should be relatively simple.
I haven't tested this, but you should be able to ask your database for the filtered data when your name field throws the blur event, and update the source option on the autocomplete component. If your data is all client-side, then you'll have to write a little JavaScript filter on your array.
It could look something like this:
var filterData = function() {    $('input[name="address"]').disable().val('Loading addresses...'); // optional ui helper    $.ajax({        ...        success: function( data ) {            if ( data.success ) {                $('input[name="address"]').enable().val( data.results[0] ); // optional ui helper                $('input[name="address"]').autocomplete( 'source', data );            }        }    });}
<input type="text" name="name" placeholder="Please enter your name." onblur=filterData()></input><input type="text" name="address" placeholder="Please enter your address."></input>

Something like that anyway. Hope that helps. This is probably the line you are looking for (in Smalltalk):
renderComponentOn: html    | someData | someData = [].    ...    (html jQuery: '#theAddressField') autocomplete optionAt: 'source' put: someData.
RS
> Date: Mon, 27 Aug 2012 06:35:41 -0700
> From: lasmiste at gmail.com
> To: seaside at lists.squeakfoundation.org
> Subject: [Seaside] JQuery ui autocomplete with multiple parameters
> 
> Hi there,
>  I'm struggling with JQuery ui autocomplete. 
> I've a form with a couple of input fields: "name" and "address". Actually
> autocomplete is running on the "address" field (I've a list of addresses and
> names of my town), so far so good.
> 
> Now, I'm gonna try to have an autocompletion of the "address" and "name"
> coupled together, e.g. user fills the "name" field (e.g. John Smith) and
> when he is starting to fill the "address" field, the returning values from
> autocomplete should be the list of addresses of John Smith.
> What I'm wondering is how to pass the value of the "name" field to the
> autocomplete so that I can use "name" and "address" together in my query 
> Thanks
>  Dave
> 
> 
> 
> --
> View this message in context: http://forum.world.st/JQuery-ui-autocomplete-with-multiple-parameters-tp4645397.html
> Sent from the Seaside General mailing list archive at Nabble.com.
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20120827/3b874b42/attachment.htm


More information about the seaside mailing list