hello guys I came a cross a little problem which I couldn’t solve:
I am using Swiper for an input like this:
and this is the code for the swiper:
if(self.emojiSwiper)
self.emojiSwiper.destroy(false,false);
self.emojiSwiper = app.swiper.create('.swiper-container.emoji-swiper', {
initialSlide: self.emoji.length,
spaceBetween: 10,
navigation: {"nextEl": ".swiper-button-next", "prevEl": ".swiper-button-prev"},
loop:true,
slidesPerView:"auto",
centeredSlides:true,
on: {
init: function () {
const swiper = this;
var active = swiper.slides.eq(swiper.activeIndex).data('emoji');
app.form.fillFromData('#formCreateEvent', {emoji:active});
},
slideChange: function () {
const swiper = this;
var active = swiper.slides.eq(swiper.activeIndex).data('emoji');
app.form.fillFromData('#formCreateEvent', {emoji:active});
}
}
});
What is the idea? it displays some preset emojis to choose from, but gives you the possibility to input your own emoji, the only problem is because swiper is in loop it creates the input like 3 times. so upon submit it takes the last input as the selected emoji, which means no matter if i input something into the field or not it will not use it.
when submitting the form i use the app.form.convertToData, and i only recieve for the emoji input the last one which is not the input emoji. the input emoji is always in the same order so,
i couldn’t figure out a good idea to solve that problem