真正刷新/重新加载jQuery移动页面div

时间:2014-08-12 19:57:07

标签: javascript jquery jquery-mobile mobile

我目前正在使用包含多个jQM页面div的文件(单页方法)。 我在这些页面的标题中有一个刷新按钮,我试图根据" getActivePage"来刷新单个页面div。这种交互性的原因是存在用户需要刷新以查看进入列表视图的新内容的项目的运行列表。

我有各种视觉刷新改变了以下功能,但似乎没有一个完全刷新DOM或所需页面容器或jQM页面div的内容。通过以下代码,我能够看到视觉转换,并且我到达了我想要刷新的所需/相同的jQM页面div。问题是,内容似乎并没有真正重新加载。 (我在更改列表视图以测试刷新的测试环境中有一种方法,我没有看到这些更改生效)我想知道我是否没有传入" id_urlNav& #34;正确或如果甚至可以使用.pagecontainer("更改" ...)。

当全部丢失时,我最终插入了window.location.reload();,但这似乎是pagecontainer操作的不良形式。如果有人知道为什么这不起作用,请告诉我。在此先感谢您的审核!

// script to reload/refresh jQM pages
// scoped to internal page hashes vs. overall window
// "change" is used vs. "load" for internal reloads vs. AJAX content
function refreshPages() {
// the camel casing on the first part of the pageContainer object below
// is important
var id_url = $.mobile.pageContainer.pagecontainer("getActivePage")[0].id;
var id_urlNav = "#" + id_url;
console.log("id_urlNav" + " =" + " " + id_urlNav );
// window.location.reload();

// keeping the below in case 1.5 finally arives with proven solution
$.mobile.pageContainer.pagecontainer( "change", id_urlNav, 
  {
    allowSamePageTransition : true,
    showLoadMsg             : true,
    // reloadPage reloads entire jQM set of pages, forgetting the getActivePage
    // reloadPage is deprecated
    // reload "reloads" the getActivePage, but doesn't show new content
    reload                  : true,
    transition              : 'fade', 
    changeHash              : 'true'
    } 
);
}
// /refresh code

我在jQuery论坛上看到一些关于重新加载的错误:与现在已弃用的reloadPage:但我不知道这是否是导致故障的原因。

0 个答案:

没有答案
相关问题