我有一個奇怪的情況,因爲我的Yii框架本身會生成註銷鏈接並將其放在每個元素的視圖體中(span,div,li等) 通過這個問題,的視圖我得到註銷
要生成視圖我用$ this-> render();
在結果DOM是這樣的:
<section class="top-line">
<div class="right">
<a href="/workflow/?r=user/logout"> </a>
</div>
<a href="/workflow/?r=user/logout"> </a>
</section>
<a href="/workflow/?r=user/logout">
<div class="main-box">...</div>
</a>
<footer>
<a href="/workflow/?r=user/logout"> </a>
<div class="container">..</div>
</footer>
@DarkMukke包括佈局/ main.php:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="language" content="en" />
<link rel="shortcut icon" href="<?php echo Yii::app()->request->baseUrl; ?>/favicon.ico" type="image/x-icon" />
<!-- blueprint CSS framework -->
<link rel="stylesheet" type="text/css" href="<?php echo baseUrl(); ?>/css/screen.css" media="screen, projection" />
<link rel="stylesheet" type="text/css" href="<?php echo baseUrl(); ?>/css/print.css" media="print" />
<!--[if lt IE 8]>
<link rel="stylesheet" type="text/css" href="<?php echo baseUrl(); ?>/css/ie.css" media="screen, projection" />
<![endif]-->
<link rel="stylesheet" type="text/css" href="<?php echo baseUrl(); ?>/css/form.css" />
<link rel="stylesheet" type="text/css" href="<?php echo baseUrl(); ?>/css/blue/style.css" />
<?php
$cs = cs();
$cssCoreUrl = $cs->getCoreScriptUrl();
$cs->registerCssFile($cssCoreUrl . '/jui1.9.2/css/base/jquery-ui.css');
$cs->registerCoreScript('jquery');
$cs->registerCoreScript('jquery.ui');
$cs->registerCoreScript('cookie');
$cs->registerScriptFile('js/block.js');
$cs->registerScriptFile('js/global.js');
$cs->registerScriptFile('css/blue/style.js');
?>
<title><?php echo CHtml::encode($this->pageTitle); ?></title>
</head>
<body>
<header class="top">
<div class="container">
<div class="logo">
<h1><a href="<?php echo Yii::app()->baseUrl; ?>" ><?php echo CHtml::encode(Yii::app()->name); ?></a></h1>
</div>
<nav>
<?php $this->widget('Menu'); ?>
</nav>
</div>
</header>
<section class="top-line">
<div class="container">
<?php if (isset($this->breadcrumbs)): ?>
<div class="left">
<?php
$this->widget('zii.widgets.CBreadcrumbs', array(
'links' => $this->breadcrumbs,
));
?>
</div>
<?php endif ?>
<?php if (Yii::app()->user->isGuest == false): ?>
<div class="right">
<a href="<?php echo url('/user/logout'); ?>"><?php echo t('Logout') . ' (' . Yii::app()->user->name . ')'; ?>
</div>
<?php endif; ?>
</div>
</section>
<div class="main-box">
<div class="container clear">
<div class="clear cenetr">
<?php
foreach (Yii::app()->user->getFlashes() as $key => $message) {
echo '<div class="flash-' . $key . '">' . $message . " <span class=\"close-flush-btn\"></span></div>\n";
}
?>
</div>
</div>
<div class="wrapper">
<?php echo $content; ?>
</div>
</div>
<footer>
<div class="container">
<div class="wrapper">
<div class="fleft"><?php echo Yii::app()->params['copyrightInfo']; ?></div>
<div class="fright"><?php echo Yii::powered(); ?></div>
</div>
</div>
</footer>
</body>
有沒有人有這個問題?這可能是由此類行爲造成的。
[解決]我的愚蠢的錯誤。不要在註銷鏈接中關閉標籤,並在每次點擊時對身體做出反應。真是遺憾..謝謝你的關注。
你可以發佈你的/protected/views/layout/main.php嗎? – DarkMukke
那些'block.js'和'global.js'腳本是什麼?我認爲註銷鏈接添加在客戶端(通過JavaScript),而不是在服務器端(Yii)。 – CedX