I have a cake application running on my local server. What I am trying to do now is autocomplete.
autocomplete
agencies_controller:
var $helpers = array('Paginator', 'Html', 'Form', 'Javascript', 'Ajax');
var $components = array('Filter', 'RequestHandler', 'Session');
function autoComplete() {
$this->set('agencies', $this->Agency->find('all', array(
'conditions' => array(
'Agency.agency LIKE' => $this->data['Agency']['agency'].'%'
),
'fields' => array('agency'))));
$this->layout = 'ajax';
}
agencies search.ctp:
echo $javascript->link('prototype', false);
<?php echo $this->Form->create('Agency');?>
echo $ajax->autoComplete('Agency.agency', '/agencies/autoComplete')
echo $this->Form->end(__('Search', true)); ?>
agencies auto_complete.ctp:
<ul>
<?php foreach($agencies as $agency): ?>
<li><?php echo $agency['Agency']['agency']; ?></li>
<?php endforeach; ?>
</ul>
What is wrong about my code with the autocomplete function? Why doesn’t it work?
Update
Firebug output:
Ajax.Autocompleter is not a constructor
<script type="text/javascript">
//<![CDATA[
new Ajax.Autocompleter('AgencyAgency', 'AgencyAgency_autoComplete', '/agencies/test', {});
//]]>
</script>
The problem was about scripts. I forget to place scriptaculous to
jsfolder.