Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery mobile jQuery Mobile-pagecontainer更改时未触发事件_Jquery Mobile - Fatal编程技术网

Jquery mobile jQuery Mobile-pagecontainer更改时未触发事件

Jquery mobile jQuery Mobile-pagecontainer更改时未触发事件,jquery-mobile,Jquery Mobile,我想在加载页面时滚动到特定的div。jquerymobile1.4。 如果只是加载页面,它可以正常工作,但是如果使用API加载,它就不工作 使用API加载 $('#schedule-a-call-collapsible').on("collapsibleexpand", function(event, ui){ $( "body" ).pagecontainer( "change", 'schedule-a-call-mobile.html', {transition: 'sli

我想在加载页面时滚动到特定的div。jquerymobile1.4。 如果只是加载页面,它可以正常工作,但是如果使用API加载,它就不工作

使用API加载

$('#schedule-a-call-collapsible').on("collapsibleexpand", function(event, ui){
        $( "body" ).pagecontainer( "change", 'schedule-a-call-mobile.html', {transition: 'slideup'} );
}
卷轴刚刚好

Behave.prototype.doScrollTop = function(element) {
  var pos = $(element).offset().top;
  pos -= $('div.ui-header-fixed').outerHeight();
  $("html, body").animate({ "scrollTop": pos }, 500);
};
事件不会被触发

jQuery('body').on("pagecontainershow", function (e, ui) {
    console.log("scrolling timezone");
    console.log(jQuery('#schedule-a-call-timezone').offset().top);
    $('#schedule-a-call-timezone-col').collapsible('expand');
    behave.doScrollTop(jQuery('#schedule-a-call-timezone-col'));
});
其基本原理是,在膨胀可压缩流体时,流动变得更加复杂。我想隐藏其他可折叠选项,除非有人滚动并单步执行工作流,就像它是一组新的页面一样

谢谢
John

解决方案是只使用location.href

$('body').delegate('#collapsible-schedule-a-call', "collapsibleexpand", function (e, ui) {
  e.preventDefault();
  document.location.href = 'schedule-a-call-mobile.html';
});
侦听的事件已更改,以便完全避免pagecontainershow事件


根本原因是试图使一个站点具有不同于桌面转换的移动转换,如在移动设备上向左滑动等。当涉及到其他框架时,jquery mobile是一个挑战。

您将pagecontainershow的代码放在哪里?不管我是将其放在data role=页面的底部还是在close body I之前不要认为这是可能的,只需设置location.href即可。jqm文档说,不能使用任何转换加载多页html,这就是问题所在。ajax不能加载页面集合,因为它是ajax加载的,所以它不会运行“pagecontainershow”。你是在单页面模型和多页面模型之间混合吗?从一个页面容器到另一个页面容器。这是一个子工作流。