我是第一次使用jQuery移动框架。我已经复制了示例代码从网站的列表视图。根据文档,它应该做一个AJAX调用,然后更新DOM。
当我点击一个链接,ajax加载图标弹出正确。然后页面重新加载,其中唯一的单词是"undefined"。
我正在使用CakePHP,它已经拉在我的移动布局。如果我重新加载页面,我将获得正确的页面视图。
谁能告诉这个"未定义"的消息是从哪里来的,以及如何得到这个工作?
谢谢,安迪
编辑:包含代码
// mobile layout
<div data-role="page" class="type-interior">
<div class="content-primary">
<p><?php echo $content_for_layout; ?></p>
</div><!-- /content -->
</div><!-- /page -->
// gallery view
<div data-role="header">
<h1>My heading</h1>
</div><!-- /header -->
<ul data-role="listview" data-filter="true">
<li><?php echo $this->Html->link('Gauteng',array('controller'=>'regions','action'=>'gallery',4)); ?></li>
<li><?php echo $this->Html->link('Western Cape',array('controller'=>'regions','action'=>'gallery',1)); ?></li>
<li><?php echo $this->Html->link('Eastern Cape',array('controller'=>'regions','action'=>'gallery',2)); ?></li>
<li><?php echo $this->Html->link('Northern Cape',array('controller'=>'regions','action'=>'gallery',9)); ?></li>
<li><?php echo $this->Html->link('Free State',array('controller'=>'regions','action'=>'gallery',3)); ?></li>
<li><?php echo $this->Html->link('Mpumalanga',array('controller'=>'regions','action'=>'gallery',7)); ?></li>
<li><?php echo $this->Html->link('Kwa-Zulu Natal',array('controller'=>'regions','action'=>'gallery',5)); ?></li>
<li><?php echo $this->Html->link('North West',array('controller'=>'regions','action'=>'gallery',8)); ?></li>
<li><?php echo $this->Html->link('Limpopo',array('controller'=>'regions','action'=>'gallery',6)); ?></li>
</ul>
点击这些结果中的任何一个,页面显示为"未定义"。它有移动布局,但没有读取正确的视图文件。
编辑:谷歌广泛地发现了一个类似的问题在这里回答stackoverflow,但当我试图改变布局在beforeRender方法然后ajax永远不会完成。我用firebug跟踪了网络流量,可以看到http get请求成功完成,并返回了正确的页面信息(整个页面)。但是,JQM没有更新视图。
我又遇到了这个问题,并认为在这里注明解决方案可能会对人们有所帮助。第二次遇到这个问题是因为我使用的是CakePHP,需要在视图文件的顶部包含正确的div标记,以便AJAX调用能够检测传入的内容。