Ajax.AutoCompleter function using the option 'with'
CODE:
<?php echo $ajax->autoComplete('Model.fieldname', '/controller/
autoComplete', array('with' => '$(Models.FieldName2).serialize()'))?>
BUT, the problem is, this isn't asynchronous, this just passes the
value of FieldName2 as a serialized string upon creation of the
AutoCompleter.
If FieldName2 changes afterwards, which it is likely to do, there is
no way to communicate the update to the AutoCompleter object.
That seems odd to me, this scenario has to have occurred before.
My test page here: http://66.235.15.212/hicake/ has a hack that seems
to work half the time, where a new AutoCompleter is created every time
the city field is changed, but its definitely the wrong way to do
this.
On Jun 25, 1:18 am, hoyos <andrew.hatte...@gmail.com> wrote:
> I have a simple search form that I am attempting to add Ajax
> autocomplete funtionality to:
>
> The form consists of:
>
> 1. A dropdown selector that allows you to select a city ("NYC", "LA",
> "BOS" for example)
> 2. A search box.
>
> I have autocomplete working fine under the normal configuration, but
> the problem is that the autocomplete results are not restricted to the
> selected city.
>
> I cannot figure out how to pass the Search term AND the city value to
> the autocomplete function.
>
> Here is the relevant code:
>
> [FROM VIEW]
> <?php echo $form->input('Restaurant.metro', array('options' => array
> ('SEA', 'NYC', 'LA'), 'label' => '')); ?>
> <?php echo $ajax->autoComplete('Restaurant.name', '/restaurants/
> autoComplete')?>
>
> [FROM CONTROLLER]
> function autoComplete() {
> $this->set('restaurants', $this->Restaurant->find('all', array(
> 'conditions' => array(
> 'Restaurant.name LIKE' => $this->data['Restaurant']['name'].'%',
> //'Restaurant.metro LIKE' => $this->data['Restaurant']['metro']
> <-- NEED TO GET data['Restaurant']['metro'] TO CONTROLLER AS WELL
> ),
> 'fields' => array('name'),
> 'limit' => 20
> )));
> $this->layout = 'ajax';
> }
>
> Any insight would be much appreciated
--~--~---------~--~----~------------~-------~--~----~
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:
Post a Comment