2013-09-21 26 views
2

我在一个jQuery移动网络应用程序的工作动态内容的问题。我试过整合dangero.us swiper。 我使用动态html填充swiper-container。我已经尝试在插入html之后使用reinit()函数,就像在其他任务中描述的那样,但没有任何事情发生。jQuery Mobile的使用dangero.us刷卡

这是我的html:

<div data-role="page" id="slider"> 
    ..... 
    <div class="swiper-container"> 

     <div class="swiper-wrapper"> <!-- wrapper --> 


      <div id="slidecontent"></div> <!-- dyn. html here --> 


     </div> <!-- wrapper --> 

</div> 

这是我的填充动态内容的代码,初始化刷卡实例的呼叫重新发起() - 函数在我的浏览

$('#slider').on('pageinit', function(event) { 

    $('#slidecontent').load('slider_input.html').trigger("create"); 

    // div containers loading 

}); 


    $(document).on('pageshow', '#slider', function(){ 

var myapp2goSwiper = $('.swiper-container').swiper({ 
    pagination: '.pagination', 
    paginationClickable: true, 
    slidesPerView: 1, 
    loop: true, 
     onSlideClick : function(swiper) { 
     //Do something when you touch the slide 

     var i = myapp2goSwiper.clickedSlideIndex; 

     var a = myapp2goSwiper.activeSlide(); 

     console.log(i); 

     console.log(a); 

     } 


}); 

//myapp2goSwiper.reInit(); 
reinitSwiper(myapp2goSwiper); 

}); 


function reinitSwiper(swiper) { 
setTimeout(function() { 
    swiper.reInit(); 
}, 500); 

};  

不显示任何。我能做些什么来刷新或重新启动我的html内容,swiper-instance正常工作?同住的演示是在http://www.m.myapp2go.de/myapp2go-slide.html

我解决我的问题。将我的html内容附加到<div id="slidecontent"></div>是错误的。我必须直接将HTML内容附加到<div class="swiper-wrapper">

现在,它的工作,但:

  • 分页不再被显示
  • onSlideClick不火了

有什么建议?

+0

我注意到,您的应用程序现在是工作,你能告诉你做了什么?非常感谢! –

回答

0

我试着打在刷卡的js文件的createpagination方法如下,它的工作,以更新重新发起功能分页。

前往路线在2.1版本的缩小的js文件741。将会有如下所述的reinit方法。这种方法需要被调用以重新初始化刷卡情况下,它产生dynamically.I呼吁在重新发起所述createPagination()方法,以便通过调用默认仅init方法来更新分页,具体如下:重新发起方法,以便分页没有按没有更新。

a.reInit = function(b) { 
    a.init(!0, b); 
    a.createPagination(); 
}; 

希望帮助!!!

+0

你能指定一下你做的更好吗?这是我还面临的问题,我可以摆脱它!请张贴一些代码或更好的描述..谢谢! –

+1

@SimonaAdriani:编辑我的评论。检查它是否有帮助!如果你需要更多的解释,请恢复原状。通过我的个人资料在个人资料中发送邮件。 – Silver