gpt4 book ai didi

PHP jQuery 移动 ListView 链接返回 "undefined"

转载 作者:搜寻专家 更新时间:2023-10-31 22:14:28 25 4
gpt4 key购买 nike

我是第一次使用 jQuery Mobile Framework。我已经从站点复制了 ListView 的示例代码。根据文档,它应该进行 AJAX 调用,然后更新 DOM。

当我单击链接时,ajax 加载图标会正确弹出。然后页面重新加载,其中唯一的词是“未定义”。

我正在使用 CakePHP,它已经引入了我的移动布局。如果我重新加载页面,我会获得正确的页面 View 。

任何人都可以建议这个“未定义”消息的来源以及如何让它工作吗?

谢谢, 安迪

编辑:包含代码

// 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>

点击其中任何一个会导致页面显示“未定义”。它具有移动布局,但未读取正确的 View 文件。

编辑:谷歌广泛发现类似问题answered here on stackoverflow但是当我尝试在 beforeRender 方法中更改布局时,ajax 永远不会完成。我用 firebug 跟踪了网络流量,可以看到 http get 请求成功完成并返回了正确的页面信息(整个页面)。但是,JQM 不会更新 View 。

最佳答案

我又遇到了这个问题,并认为在这里记录解决方案可能会对人们有所帮助。我第二次遇到这个问题是因为我使用的是 CakePHP,需要在我的 View 文件顶部包含正确的 div 标签,这样 AJAX 调用才能检测传入的内容。

关于PHP jQuery 移动 ListView 链接返回 "undefined",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8293381/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com