Jquery mobile JQM-运行多个页面-pageinit不工作

Jquery mobile JQM-运行多个页面-pageinit不工作,jquery-mobile,page-init,Jquery Mobile,Page Init,我最初把我的页面放在外部。但是,我想利用页面转换,所以我将每个包含Royal Slider的页面导入到index.html中。但是,Royal Slider仅在第一页上正确加载,而在另一页上不正确加载。我读过关于使用pageinit的文章,但它不起作用。我还了解了pagebeforeshow和page change,它将在每次发生页面更改时运行代码,而不是像pageinit那样只运行一次。有人能看看我的代码并帮我吗 iPhone快速参考应用程序 $(文档)。在('pagebeforeshow'

我最初把我的页面放在外部。但是,我想利用页面转换,所以我将每个包含Royal Slider的页面导入到index.html中。但是,Royal Slider仅在第一页上正确加载,而在另一页上不正确加载。我读过关于使用pageinit的文章,但它不起作用。我还了解了pagebeforeshow和page change,它将在每次发生页面更改时运行代码,而不是像pageinit那样只运行一次。有人能看看我的代码并帮我吗


iPhone快速参考应用程序
$(文档)。在('pagebeforeshow','[data role=page]',函数()上{
jQuery(文档).ready(函数($){
$(“#全宽滑块”).royalSlider({
阿罗斯纳夫:错,
循环:false,
键盘导航已启用:true,
控制侧:错误,
imageScaleMode:'fit',
arrowsNavAutoHide:错误,
自动缩放滑块:对,
自动缩放滑块宽度:640,
自动缩放滑块高度:1057,
controlNavigation:“项目符号”,
ThumbsFitView端口:false,
导航时钟:是的,
StartSlided:0,
自动播放:错误,
transitionType:“移动”,
globalCaption:错误,
深度链接:{
启用:对,
更改:错误
},
/*所有图像的大小http://help.dimsemenov.com/kb/royalslider-jquery-plugin-faq/adding-width-and-height-properties-to-images */
imgWidth:640,
imgHeight:1136,
});
});
});


我想我明白了。必须向下导航到#全宽滑块-现在脚本为每个页面运行

<script type="text/javascript">
$(document).on('pagechange', function() {
  $('[data-role=page] #full-width-slider').royalSlider({
    arrowsNav: false,
    loop: false,
    keyboardNavEnabled: true,
    controlsInside: false,
    imageScaleMode: 'fit',
    arrowsNavAutoHide: false,
    autoScaleSlider: true, 
    autoScaleSliderWidth: 640,     
    autoScaleSliderHeight: 1057,
    controlNavigation: 'bullets',
    thumbsFitInViewport: false,
    navigateByClick: true,
    startSlideId: 0,
    autoPlay: false,
    transitionType:'move',
    globalCaption: false,
    deeplinking: {
      enabled: true,
      change: false
    },
    /* size of all images http://help.dimsemenov.com/kb/royalslider-jquery-plugin-faq/adding-width-and-height-properties-to-images */
    imgWidth: 640,
    imgHeight: 1136,
  });
});
</script>

$(文档).on('pagechange',function()){
$(“[data role=page]#全宽滑块”).royalSlider({
阿罗斯纳夫:错,
循环:false,
键盘导航已启用:true,
控制侧:错误,
imageScaleMode:'fit',
arrowsNavAutoHide:错误,
自动缩放滑块:对,
自动缩放滑块宽度:640,
自动缩放滑块高度:1057,
controlNavigation:“项目符号”,
ThumbsFitView端口:false,
导航时钟:是的,
StartSlided:0,
自动播放:错误,
transitionType:“移动”,
globalCaption:错误,
深度链接:{
启用:对,
更改:错误
},
/*所有图像的大小http://help.dimsemenov.com/kb/royalslider-jquery-plugin-faq/adding-width-and-height-properties-to-images */
imgWidth:640,
imgHeight:1136,
});
});