Fullpage.js: How to test if fullpage has been initialised

Created on 23 Jun 2016  ·  2Comments  ·  Source: alvarotrigo/fullPage.js

Hi,

I'm using ajax to load page content.

When an new page loads I'm getting the following console error:
fullPage: Fullpage.js can only be initialized once and you are doing it multiple times!

OK - can't see how to test if fullpage has already been initialised.

My setup code that is being executed each page load looks like:
$( '#fullpage' ).fullpage({ ...options });

If I call the destroy or rebuild methods before the init I get the console error:
TypeError: e.fn.fullpage.destroy is not a function

Help please!

Cheers
James

question

Most helpful comment

OK. I realised that fullpage adds fp-enabled class to HTML element, so I'm testing using:

if ( $( 'html' ).hasClass( 'fp-enabled' ) ) {

  $.fn.fullpage.destroy();
}

Which works!

All 2 comments

OK. I realised that fullpage adds fp-enabled class to HTML element, so I'm testing using:

if ( $( 'html' ).hasClass( 'fp-enabled' ) ) {

  $.fn.fullpage.destroy();
}

Which works!

Check the docs for the state classes

The class fp-enabled is added to the html element when fullpage.js is enabled. (and removed when destroyed).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Sperziemone picture Sperziemone  ·  5Comments

rslcdmc picture rslcdmc  ·  3Comments

sloyer picture sloyer  ·  3Comments

festwertspeicher picture festwertspeicher  ·  4Comments

lunaandyou picture lunaandyou  ·  4Comments