获得swipeJS使用Ajax加载的内容合作 [英] Getting swipeJS to work with ajax loaded content

查看:175
本文介绍了获得swipeJS使用Ajax加载的内容合作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我提出目前在 test2.applicationcreations.net 测试网站。随着中动态地改变图像的图像库。我使用 swipeJS 为滑块。

当您导航到项目库中,然后定制的家园,新的HTML与格式正确加载,但肩不起作用。我认为,问题是,swipeJS上没有新的code初始化。我曾尝试使用 window.mySwipe =新的刷卡(的document.getElementById('滑'))通过新项目的对象; 但我有没有运气

有关,如果我点击检查元素上的Chrome 18 OS X上的转子适用于新的内容。由于某种原因,

任何帮助得到这个工作是极大的AP preciated。谢谢。

解决方案

是啊,你这样做是正确,一旦你添加了新的元素,所有你需要做的是重新初始化mySwipe对象。

这是刷卡滑块对象的第一个初始化:

  / * ------------------------------------ ----
  刷卡滑块,使触摸滑动
---------------------------------------- * /
document.mySwipe =新的刷卡(的document.getElementById('滑'){
  startSlide:0,
  速度:400,
  汽车:5000,
  回调:函数(事件,指数,ELEM){
    //做一些很酷
  }
});
 

现在只是定义其重新初始化刷卡对象的方法。

  / * ------------------------------------ ----
  重新初始化滑动滑块。
---------------------------------------- * /
document.reinit =功能(){
  document.mySwipe =新的刷卡(的document.getElementById('滑'){
    startSlide:0,
    速度:400,
    汽车:5000,
    回调:函数(事件,指数,ELEM){
      //做一些很酷
    }
  });
}
 

调用该方法,当你完成添加新的元素添加到现有的滑块。

  //完成添加新元素
document.reinit();
 

I am making a site currently being tested at test2.applicationcreations.net. With an image gallery that dynamically changes the images. I'm using swipeJS for the slider.

When you navigate to project gallery then to custom homes the new HTML with correct formatting loads in but the rotator does not work. I believe the problem is that swipeJS is not initialized on the new code. I have tried passing the new items to the object using window.mySwipe = new Swipe(document.getElementById('slider')); but I have had no luck.

For some reason if I click on inspect element on Chrome 18 OS X the rotator works with the new content.

Any help getting this working is greatly appreciated. Thank you.

解决方案

Yup, you got it right, once you have added the new element, all you need to do is reinitialize the mySwipe object.

This is the first initialization of the swipe slider object:

/*----------------------------------------
  Swipe slider to enable touch sliding
----------------------------------------*/
document.mySwipe = new Swipe(document.getElementById('slider'), {
  startSlide: 0,
  speed: 400,
  auto: 5000,
  callback: function(event, index, elem) {
    // do something cool
  }
});

Now just define a method which re-initializes the swipe object.

/*----------------------------------------
  Reinitializing the Swipe Slider.
----------------------------------------*/
document.reinit = function(){
  document.mySwipe = new Swipe(document.getElementById('slider'), {
    startSlide: 0,
    speed: 400,
    auto: 5000,
    callback: function(event, index, elem) {
      // do something cool
    }
  });
}

Call that method when you have finished adding new elements to the existing slider.

// Finished adding new elements
document.reinit();

这篇关于获得swipeJS使用Ajax加载的内容合作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆