简体   繁体   中英

WP Supersized api is undefined - why?

Hello Stackoverflow Community,

I am having a problem with the WordPress Plugin WP Supersized, since its very famous I am hoping that someone on here can help me with it.

The Plugin itself is running fine, with no special Settings. Just the Slideshow is disabled by default, since I just wanted to use fullscreen Images on all subpages except one.

On one subpage I am using jquery and the Supersized API to change the the background image onClick - which works with the following code.

$(document).ready(function() {
    // CHANGE SUPERSIZED BACKGROUND IMAGE AND CONTAINER BG COLOR ON CLICK
    $("#extensions").click(function(){
        api.goTo(4);
    });
    // START GALLERY AUTOPLAY ON AMBIENTE PAGE
    if($("body").hasClass("page-id-6")){
        api.playToggle();
    };
});

As you can see below the click() function, there is another thing which is happening when the body has a specific class assigned => setting the slideshow to play . Problem here is, that on this subpage my console tells me: "Uncaught ReferenceError: api is not defined".

My question now is, why can I access the api on one page but not on the other, even tho BOTH use WP Supersized to load multiple images into the background and both jQuery commands are loaded the same way?

Thanks for any help on this.

Solved the Problem myself.

It was caused due to double jQuery inclusion (manual inclusion inside header.php + the WP internal jQuery lib) and wrongly adresses variable scopes (jQuery instead of % etc.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM