Toggle class only affects current scene


(Markus Bjerre) #1

Hello. I’ve been trying to change language with data tags inside divs. It works great on the current scene but when I jump to the next scene with buttons and divs that has the same classes they will be replaced with their original content.
A small example is the toggle on and off using jquery:

languageDefault = $('.language');

languageDefault.on('click', function() {
    $(this).toggleClass('toggled');
    if ($(this).hasClass('toggled')) {
        summaryLang = 'summaryeng';
        homeLang = 'homeeng';
    } else {  
        summaryLang = 'summaryswe';
        homeLang = 'homeswe';
    }
    $('#summaryLang').html($('#summaryLang').data(summaryLang));
    $('#homeLang').html($('#homeLang').data(homeLang));
});

does anyone experiencing the same as I do? That classes can’t be changed over scenes?
Tried addClass and that does not help either. Still not affecting over scenes


(Hans-Gerd Claßen) #2

guess this is expected behaviour. write your changes to a global var or sessionStorage and apply it on sceneload :slight_smile:


(Markus Bjerre) #3

how would you add it to a global var @h_classen ?
Thanks for replying :slight_smile:


(Hans-Gerd Claßen) #4

summaryLang, homeLang those are the global variables you set, so simply call them on sceneload after a check if they’ve already been set …


(Markus Bjerre) #5

ye sorry for not answering but I did that later on and it worked :slight_smile: