有一个奇怪的zend框架问题。虽然它很可能很简单,但到目前为止我还是无法解决它。我已经删除了stackOverflow和其他几个社区站点的底部,以及zend文档。
我在布局中包含的任何ajaxLink都拒绝运行。它们被正确分类,在href属性中使用哈希占位符,但激活链接的javascript未包含在页面中。
布局中的 echo $this->jQuery;
语句也失败了。可能是ajaxLink失败的原因。我已经验证我正在我的bootstrap中正确添加jQuery视图助手。尝试过使用ZendX_JQuery::enableView($view);
和$view->addHelperPath("ZendX/JQuery/View/Helper", "ZendX_JQuery_View_Helper");
方法。
提前致谢
相关文件的摘录如下:
bootstrap.php中:
protected function _initViewHelpers()
{
$this->bootstrap('layout');
$layout = $this->getResource('layout');
$view = $layout->getView();
$view->doctype('HTML4_STRICT');
$view->headMeta()->appendHttpEquiv('Content-type', 'text/html;charset=utf-8')
->appendName('description', 'Business Club');
$view->headTitle()->setSeparator(' - ');
$view->headTitle('SOU Business Club');
$view->setHelperPath(APPLICATION_PATH.'/views/helpers', '');
ZendX_JQuery::enableView($view);
}
dashboardLayout.phtml:
<?php echo $this->doctype();?>
<html>
<head>
<?php echo $this->headTitle();?>
<?php echo $this->headMeta();?>
<?php
echo $this->headLink()->prependStylesheet($this->baseUrl().'/css/dashboardStyle.css');
echo $this->headLink()->prependStylesheet($this->baseUrl().'/js/jquery/css/smoothness/jquery-ui-1.8.11.custom.css');
?>
<?php
echo $this->headScript()->appendFile($this->baseUrl().'/js/paginator.js');
echo $this->jQuery();
?>
</head>
<body id="body">
<div id="wrapper">
<div><?php include "dashboardHeader.phtml"; ?></div>
<div id="bar">
<a href="<?php echo $this->url(array('controller'=>'dashboard', 'action'=>'home'))?>">Dashboard Home</a>|
<?php
echo $this->ajaxLink('Club Roster | ',
'user/index',
array('update' => '#content',
'method' => 'post'),
array('format' => 'html')
);
?>
<a href="<?php echo $this->url(array('controller'=>'gdata', 'action'=>'index'))?>">Google Docs</a>|
<a href="<?php echo $this->url(array('controller'=>'books', 'action'=>'index'))?>">Book Sale Management</a>|
</div>
<div id="content" align="center">
<?php
echo $this->layout()->content;
?>
</div>
<div id="statusBar">
<?php
$userData = Zend_Registry::get('userData');
$name = $userData->name;
$role = $userData->role;
$status = 'Logged in as: '.' Name: '.$name.' Role: '.$role;
echo $status;
?>
<br />
<a href="<?php echo $this->url(array('controller'=>'authentication', 'action'=>'logout'))?>">Logout</a>
</div>
<div><?php include "dashboardFooter.phtml"; ?></div>
</div>
</body>
</html>
HTML <head>
输出:
<head>
<title>SOU Business Club - Member Dashboard</title>
<meta http-equiv="Content-type" content="text/html;charset=utf-8" >
<meta name="description" content="Business Club" >
<link href="/css/dashboardStyle.css" media="screen" rel="stylesheet" type="text/css" >
<link href="/js/jquery/css/smoothness/jquery-ui-1.8.11.custom.css" media="screen" rel="stylesheet" type="text/css" >
<link href="/css/dashboardStyle.css" media="screen" rel="stylesheet" type="text/css" >
<script type="text/javascript" src="/js/paginator.js"></script>
</head>
答案 0 :(得分:0)
在您的引导程序中,您需要在本地计算机或CDN上指定jQuery的位置。你在当地使用:
$view->jQuery()->setLocalPath(PATH);
或者你可以使用谷歌的CDN:http://code.google.com/apis/libraries/devguide.html#jquery
答案 1 :(得分:0)
查看我在此处发布的有关布局中所有ZendX_Jquery问题的答案。