gpt4 book ai didi

javascript - jQuery Mobile 在点击时刷新当前页面

转载 作者:太空宇宙 更新时间:2023-11-04 11:15:28 25 4
gpt4 key购买 nike

我在移动查询中有一个多页面模板。如何在单击超链接或按钮时刷新当前页面?我正在使用 JQM 版本 1.4.5

我尝试使用 how to refresh(reload) page when click button in Jquery mobile 中建议的以下代码, 但是,它没有按预期工作:

// Refresh the store main page - experimental
$(document).on('click', '#aStoreReload', function (event) {
$.mobile.changePage(window.location.href, {
allowSamePageTransition: true,
transition: 'none',
showLoadMsg: false,
reload: true // tried reloadPage: true also
});
});

它将按原样返回带有 URL 的主页。我的意思是本地服务器中的 http://localhost:56235/main.html#storeMainPage。然而,JsBin正在显示空白页,而 jsfiddle什么也不做。单击商店链接以获取具有刷新按钮的页面。

如何以正确的方式刷新页面( View )?

编辑

我也在点击事件中尝试了以下脚本:

$.mobile.changePage($("#storeMainPage"), { transition: 'slidedown' });
$(document).pagecontainer("load", "#storeMainPage", { reload: true });

第一个 like 什么都不做,第二行给出错误 Uncaught Error: cannot call methods on pagecontainer prior to initialization;试图调用方法“加载”,这是正常的,因为我们在初始化之前调用 pagecontainer。

最佳答案

使用 pagecontainer 小部件的更改方法(不加载):

$(document).on("pagecreate","#storeMainPage", function(){ 
$(document).on('click', '#aStoreReload', function (event) {
$( ":mobile-pagecontainer" ).pagecontainer("change", "#storeMainPage", { reload : true, allowSamePageTransition : true, transition : "none" });
});
});

这将导致 pageshow 事件重新触发。

Updated FIDDLE

关于javascript - jQuery Mobile 在点击时刷新当前页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33276038/

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