ZendX jQuery Autocomplete not working in framework

472 Views Asked by At
  • I added the ZendX library.
  • Added the helper in controller:
public function init()
{
    $this->view->addHelperPath(
        'ZendX/JQuery/View/Helper'
        ,'ZendX_JQuery_View_Helper');
}
  • Created a form for view page:
public function indexAction()
{
    // Filter form 
    $this->view->autocompleteElement = new ZendX_JQuery_Form_Element_AutoComplete('txtLocation');
    $this->view->autocompleteElement->setAttrib('placeholder', 'Search Location');
    $this->view->autocompleteElement->setJQueryParam('data', array('Manila', 'Pasay', 'Mandaluyong', 'Pasig', 'Marikina','Makati'));
}
  • Load jQuery and form in view page.
<?php echo $this->jQuery(); ?> 
<form>
    <?php echo $this->autocompleteElement; ?>
</form>

The form is visible in the view page. But the autocomplete isn't working. I even don't see any jQuery script in the source page. Have I missed something?

1

There are 1 best solutions below

0
Majinbibo On

I just found the solution here: http://forums.zend.com/viewtopic.php?f=69&t=1889

Adding echo $this->jQuery(); at the end of my view file instead of on the top solves the problem. I don't know what's the difference. Maybe an issue with Zend's layout generator.