On ModuleSwicher.php, a plugin for managing modules, I have the following source:
- Code: Select all
<?php
class App_Controller_Plugin_Admin_ModuleSwitcher extends Zend_Controller_Plugin_Abstract
{
protected $_view = null;
public function routeShutdown (Zend_Controller_Request_Abstract $request)
{
$moduleName = $request->getModuleName();
Zend_Layout::startMvc();
$layout = Zend_Layout::getMvcInstance();
$layout->setLayoutPath('../../public/admin/layouts/scripts')->setLayout($moduleName);
$view = new Zend_View();
$view->addHelperPath('ZendX/JQuery/View/Helper/', 'ZendX_JQuery_View_Helper');
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
$viewRenderer->setView($view);
$viewRenderer->init();
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
return $request;
}
}
And on the default.phtml layout I have this:
- Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php
// Add jQuery
$this->jQuery()->enable();
echo $this->jQuery();
?>
</head>
<body>
<?php echo $this->ajaxLink("Show me something", "/", array('update' => '#foobar')); ?>
<div id="foobar" style="width: 600px; height: 200px; border: 1px solid #000"></div>
</body>
</html>
The generated html source is this:
- Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script></head>
<body>
<a href="#" class="ajaxLink1">Show me something</a>
<div id="foobar" style="width: 600px; height: 200px; border: 1px solid #000"></div>
</body>
</html>
As you can see there isn't any jQuery code in the page, only the script link to the jQuery code (which I don't know how to load a local jQuery file).
PS: on documentation it says for jQuery UI you have to write $this->jQuery()->enableUi(); but this produces a fatal error Fatal error: Call to undefined method ZendX_JQuery_View_Helper_JQuery_Container::enableUi() in /usr/local/zend/apache2/htdocs/web_projects/Platform/public/admin/layouts/scripts/default.phtml on line 35 instead of ->enableUi() I wrote ->uiEnable() and it worked.
EDIT:
I changed $this->jQuery->uiEnable(); to
- Code: Select all
echo $this->jQuery()
->addStylesheet('/js/jQuery/UI/themes/cupertino/jquery-ui-1.7.2.custom.css')
->setLocalPath('/js/jQuery/jquery-1.3.2.min.js')
->setUiLocalPath('/js/jQuery/UI/jquery-ui-1.7.2.custom.min.js');
But still not working...
EDIT2:
I changed it to:
- Code: Select all
$this->jQuery()
->addStylesheet('/admin/js/jQuery/UI/themes/cupertino/jquery-ui-1.7.2.custom.css')
->setLocalPath('/admin/js/jQuery/jquery-1.3.2.min.js')
->setUiLocalPath('/admin/js/jQuery/UI/jquery-ui-1.7.2.custom.min.js');
$this->jQuery()->uiEnable();
echo $this->jQuery();
- Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>index / index / Administration Panel</title><link rel="stylesheet" href="/admin/js/jQuery/UI/themes/cupertino/jquery-ui-1.7.2.custom.css" type="text/css" media="screen" />
<script type="text/javascript" src="/admin/js/jQuery/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="/admin/js/jQuery/UI/jquery-ui-1.7.2.custom.min.js"></script>
</head>
<body>
<a href="#" class="ajaxLink1">Show me something</a>
<div id="foobar" style="width: 600px; height: 200px; border: 1px solid #000"></div>
</body>
</html>
but when I'm clicking on the link there isn't any action, also I don't see any generated code that handle this action.

