3D FlipBook - javascript trigger action on next page

s***k@kohrmedia.lu
2021-02-24
2021-02-25

Hello,

I have a link on page 2 and an image on page 3. I want to add / remove a class on the image when I click the link. I have it working when they are on the same page. But how do I call the action on all visible pages from the javascript?

current working code (same page)

function init(c,a) {
  c.find(".testlink").on("click", function(e) {
    var image = a.$(e.target).attr("data-img");
    c.find(".img").removeClass("show");
    c.find("#"+image).addClass("show");
    });
}; init

Replies

a***r@3dflipbook.net
2021-02-25
2021-02-25

hi, the first page is initializing first all the time, so i recommend to create a global array for images there and add/remove images from other pages when page init/dispose. In the link click handler manipulate with the global array.

Also you can:

function init(c,a) {
  c.find(".testlink").on("click", function(e) {
    var layers = a.$(c[0].ownerDocument).find('.css-layer');
    var image = a.$(e.target).attr("data-img");
    layers.find(".img").removeClass("show");
    layers.find("#"+image).addClass("show");
    });
}; init
Log In to leave a comment