【发布时间】:2014-04-07 22:12:56
【问题描述】:
我正在尝试在 JQM 中编写一个 Cake 站点,但是每当我点击一个链接时,屏幕就会跳转到一个只包含“未定义”一词的页面。
检查源代码发现有一个新的 div,其中 data-role="page" 包含这个词,并且我的旧页面的原始内容保持不变。
这是我的移动视图布局:
<!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 中只有“test”这个词。我正在尝试单击页脚中的按钮来测试 Ajax 加载。
【问题讨论】: