• Hello.
    I have a strange problem with using JS on slides of this plugin.
    I use this code:

    <script>
    $(“#show-more”).click(function() {
    $(“#slider-block”).css({height: “auto”});
    $(“#show-more”).css({display: “none”});
    $(“#hide-all”).css({display: “block”});
    });
    $(“#hide-all”).click(function() {
    $(“#slider_block”).css({height: “300px”});
    $(“#hide-all”).css({display: “none”});
    $(“#show-more”).css({display: “block”});
    });
    </script>

    It’s simple, but it works only on first, second, third and the last slide. And doesn’t work on others. I’ve been trying to solve it for a last 3 days, but i don’t have any idea how.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter cleverlandsite

    (@cleverlandsite)

    And one more strange moment:
    I don’t know why, but a single click on button on the slide is perceived how double and sometimes triple click.

    Plugin Author simonpedge

    (@simonpedge)

    Maybe try inline style for each slide to achieve the same result:

    <button id=”show_more1″ onClick=”document.getElementById(‘slider_block1′).style.height=’auto’; document.getElementById(‘show_more1′).style.display=’none’;”>SHOW MORE</button>

    <div id=”slider_block1″>
    …CONTENT HERE…
    <button onClick=”document.getElementById(‘slider_block1′).style.height=’300px’; document.getElementById(‘show_more1′).style.display=’block’;”>HIDE MORE</button>
    </div>

    Alternatively, try checking the “Use window.onload event” checkbox (under “Other Settings”)

    Thread Starter cleverlandsite

    (@cleverlandsite)

    Thank you for answer.
    Yes, in my project I’m doing this: new id for each slide.
    I tried this event, but then the slider isn’t displayed at all in this case.

    Plugin Author simonpedge

    (@simonpedge)

    Any JavaScript errors in the JS Console?

    I’m doing something similar, I use diferent ids and I have the same problem, only works as expected in the 3 first sliders, and doesn′t work in a slider with 2 slides
    my javascript code is very simple:
    in slide:
    onclick=”replace();return false”
    in javascript file
    function replace() {
    document.getElementById(“div1″).style.display=”none”;
    document.getElementById(“divI”).style.display=”none”;
    document.getElementById(“div2″).style.display=”block”;
    document.getElementById(“div3″).style.display=”none”;
    document.getElementById(“div4″).style.display=”none”;
    }
    The console doesn′t show errors, in the chrome inspector you can see the properties “display” change but the content doesn’t change

    • This reply was modified 6 years, 2 months ago by daherrerac.
    Plugin Author simonpedge

    (@simonpedge)

    Hmmm. Tough because I haven’t been given a URL to look at.
    cleverlandsite:
    Is “#slider-block” present in each slide? If so, you should not be using a CSS ID – CSS IDs should be unique. Rather use the CSS class “.slider-block”.

    daherrerac:
    Same problem possibly. If you have multiple sliders with an element with a CSS ID of “div1”, that’s incorrect – CSS IDS should be unique to the page.

    Hi, thanks for your answer. I used diferents ids for each slide (div1, div2, div1a, etc). And the slider 4 doesn’t work (is a slider with 7 slides and 4 slides in a desktop xl), and i made the same thing in a slider with 2 slides and doesn’t show the change that I need.
    I’m going to publish again the slides and give to you the url

    Hi, here is the url, the code only works in two slides
    Page

    Hi, any idea?

    Hi, so I can′t use javascript code in the sliders, can I? Why in the page the javascript code doesn`t work and the code is the same for the other slider that works (two slides)

    Plugin Author simonpedge

    (@simonpedge)

    I built Slide Anything with the intention of allowing users to create custom HTML slide content (also possibly embedded iframes). Using interactive JavaScript in slide content was not on my radar, and it is not something I’ve ever tested for.

    If you are having issues with your JS code, it is most likely an issue with Owl Carousel – I have built my plugin using the Owl Carousel engine, which I do not modify at all:
    https://owlcarousel2.github.io/OwlCarousel2/

    The OC GitHub page is:
    https://github.com/OwlCarousel2/OwlCarousel2
    You might want to browse around here. If you find the solution, could you possibly share it here – there are others that would probably find it useful.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Problems with JS on slides’ is closed to new replies.