我試圖在JQM中編寫一個Cake網站,但每次點擊一個鏈接時,屏幕都會跳轉到只包含單詞「Undefined」的頁面。CakePHP - jQuery Mobile返回包含單詞「Undefined」的空白頁
檢查源代碼顯示存在一個包含此單詞的data-role =「page」的新div,並且舊頁面的原始內容保持不變。
這是我移動視圖佈局:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title><?php echo (isset($title_for_layout)) ? $title_for_layout : 'My default title';?></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php
// javascript
$javascripts = array(
'jquery',
'jquery.mobile-1.0.min.js',
);
echo $this->Html->script($javascripts);
// css
$css = array('jquery.mobile-1.0.css','jquery.mobile.structure-1.0.css','themes/mobires.css');
echo $this->Html->css($css) . "\n\t";
?>
</head>
<body>
<div data-role="page">
<?php echo $this->Session->flash(); ?>
<div data-role="header">
<h1>
<?php echo (isset($title_for_layout)) ? $title_for_layout : 'My default title';?>
</h1>
<div data-role="navbar">
<ul>
<li><?php echo $this->Html->link('Home',array('controller'=>'pages','action'=>'display','home'))?></li>
<li><?php echo $this->Html->link('Contact',array('controller'=>'pages','action'=>'display','contact'))?></li>
</ul>
</div><!-- /navbar -->
</div><!-- /header -->
<div data-role="content">
<?php
echo $this->Session->flash();
echo $content_for_layout;
?>
</div>
<!-- start footer -->
<div data-role="footer">
© 2012<?php if (date("Y") > 2012) { echo '-' . date("Y"); } ?> Mobires. All Rights Reserved.
<br />
<?php echo $this->Html->link('Privacy Policy',array('controller'=>'pages','action'=>'display','privacy'))?>
<?php echo $this->Html->link('Terms & Conditions',array('controller'=>'pages','action'=>'display','terms'))?>
</div>
</div><!-- /page -->
<?php echo $this->Js->writebuffer(); ?>
</body>
</html>
和我home.ctp只是有單詞「測試」在裏面。我試圖單擊我的頁腳中的按鈕作爲測試Ajax加載的方式。
你可以也可以在cakephp中使用新的主題功能來查看視圖 – Martin 2014-04-07 14:12:28