我想使用ZendX_Jquery自动完成中的部分,,这是在我的布局。我怎么能做到这一点:我的布局:
<div class="prefix_11 grid_5" id="header_search_engine">
<?php echo $this->partial("/common/_search_engine.phtml"); ?>
</div>行动:
public function autocompleteAction($search='') {
$this->view->autocompleteElement = new ZendX_JQuery_Form_Element_AutoComplete('ac');
$this->view->autocompleteElement->setJQueryParam('source', '/searchengine/getsearch');
$this->view->autocompleteElement->setJQueryParam('minLength',
$this->configApplication->autocomplete->max_cars);
}我如何使用它的部分,在布局?
如何在部分视图中发送autocompleteElement?
多谢帮忙。
法布里斯
发布于 2011-08-17 09:39:16
@fabrice
我在布局中使用自动完成时也遇到了同样的问题,我已经用以下方法解决了这个问题:
searchBox
设置占位符
示例:
class myLibrary_Controller_Plugin_SearchBox extends Zend_Controller_Plugin_Abstract
{
public function preDispatch()
{
$this->searchBox();
}
public function searchBox()
{
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
$viewRenderer->initView();
$view = $viewRenderer->view;
$searchForm = new Application_Form_JQueryForm();
$searchForm->acProduct->renderUiWidgetElement();
$view->placeholder('searchBox')->set($searchForm);
}
}关键是启动方法renderUiWidgetElement();。如果没有它,布局将不会将蜜源javascript添加到自动完成元素中。我从这里得到的信息是:http://cientouno.be/blog/categorie/zend-framework
非常感谢您的光临!
发布于 2010-10-11 15:25:07
谢谢,但是,我使用ActionStack在每一页上显示。我用了一张表格。
public function autocompleteAction() {
$formAutoComplete = new Frontoffice_Form_Autocomplete();
$this->view->autocompleteElement = $formAutoComplete;
$this->_helper->viewRenderer->setResponseSegment('autocomplete');
}在布局上:
<div class="prefix_10 grid_6" id="header_search_engine">
<?php echo $this->partial("/common/_search_engine.phtml");
echo $this->layout()->autocomplete;
?>
</div>发布于 2010-10-11 13:26:58
可以使用此代码在部分视图中发送autocompleteElement。
<div class="prefix_11 grid_5" id="header_search_engine">
<?php echo $this->partial("/common/_search_engine.phtml", array('autocompleteElement ' => $this->autocompleteElement); ?>
</div>https://stackoverflow.com/questions/3899961
复制相似问题