Is it possible to add or remove slides in runtime using FlexSlider?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- How to fix IE ClearType + jQuery opacity problem i
- void before promise syntax
- jQuery add and remove delay
This is just what I saw after looking at this thread.
The slider and the carousel object can be instantiated and added to like this:
The click on the carousel to scroll to the particular image doesn't work, but the scroll buttons on both work.
The new version of FlexSlider 2 already supports this methods.
slider.addSlide(obj, pos)
accepts two parameters, a string/jQuery object and an index.slider.removeSlide(obj)
accepts one parameter, either an object to be removed, or an index.The actual implementation of FlexSlider doesn't support it.
If you modify the actual implementation to return the slider object, with this object you can stop the slider, remove the slide you want and then recreate the slider.
After trying lots of different ideas, I got this solution to add or remove a new image or video in Flexslider dynamically and its working fine.
JQuery code:
HTML code:
as per the code, with browse file, you can select multiple images and videos to add in Flexslider and with remove button, you can remove a current slide.I also added some validation so only image or video will be add in a slider. It will give an alert if you select any other extension. I created this code as per my requirement, you can customize it accordingly to your requirements.