ionic-wizard icon indicating copy to clipboard operation
ionic-wizard copied to clipboard

Cannot read property 'slideNext' of undefined

Open zeeshan-m opened this issue 8 years ago • 3 comments

The error is thrown on:

            scope.$on("wizard:Next", function() {
                scope.swiper.slideNext(true);
            });

I copied over the sample wizard from here: https://plnkr.co/edit/azYKSAYOMv0pZu8YEWVs and I get the "Cannot read property 'slideNext' of undefined" whenever I hit next in the wizard. ionic.wizard is added as a dependency into the app and ion-wizard.js is loaded. Any idea what's going wrong?

zeeshan-m avatar Aug 13 '16 14:08 zeeshan-m

Did you resolve this? If so, how?

frey1esm avatar Oct 31 '16 12:10 frey1esm

  const [swiper, setSwiper] = React.useState(null);

  const nexto = () => {
    swiper.slideNext();
  };
  return (
    <div>
      <Swiper
        spaceBetween={50}
        slidesPerView={1}
        onSwiper={(s) => {
          console.log("initialize swiper", s);
          setSwiper(s);
        }}
      >
        <SwiperSlide style={{ height: 100 }}>Slide 1</SwiperSlide>
        <SwiperSlide>Slide 2</SwiperSlide>
        <SwiperSlide>Slide 3</SwiperSlide>
        <SwiperSlide>Slide 4</SwiperSlide>
      </Swiper>
      <button onClick={nexto}>next</button>
    </div>
  );
}

jxnx888 avatar Oct 28 '22 03:10 jxnx888

  const [swiper, setSwiper] = React.useState(null);

  const nexto = () => {
    swiper.slideNext();
  };
  return (
    <div>
      <Swiper
        spaceBetween={50}
        slidesPerView={1}
        onSwiper={(s) => {
          console.log("initialize swiper", s);
          setSwiper(s);
        }}
      >
        <SwiperSlide style={{ height: 100 }}>Slide 1</SwiperSlide>
        <SwiperSlide>Slide 2</SwiperSlide>
        <SwiperSlide>Slide 3</SwiperSlide>
        <SwiperSlide>Slide 4</SwiperSlide>
      </Swiper>
      <button onClick={nexto}>next</button>
    </div>
  );
}

Thank you for helping me solve the problem

jxlagbh360 avatar Aug 09 '24 05:08 jxlagbh360