Your Cart

Adding a class to Galleria DOM elements within the theme

These forums are now closed to new replies / tickets.

Please open a support ticket from our new Support page.

Front Page Forums Problems Adding a class to Galleria DOM elements within the theme

  • gravatar
    vale
    July 11, 2015 at 4:39 pm

    Hi,
    I’m trying to modify the classic theme, inserting a button which
    will toggle a class on the galleria-thubnails-container element to
    later style it accordingly in the CSS for my purposes.

    This is my code I added to the classic theme which doesn’t
    work:

    this.addElement(‘button-thumbs’);
    var
    $thumbnailsContainer = this.$(‘galleria-thumbnails-container’),
    $buttonThumbs = this.$(‘button-thumbs’);

    $buttonThumbs.click(this.proxy(function(e) {
    $thumbnailsContainer.toggleClass(‘toggleme’);
    $buttonThumbs.toggleClass(‘onbutton’); }));
    this.appendChild(‘container’, ‘button-thumbs’);

    The class “onbutton” gets toggled fine on the button element
    itself when clicked, but the “toggleme” class doesn’t get toggled
    on the “galleria-thumbnails-container” element.

    What am I doing wrong?!

    Thanks for any given help, and pardon my noobiness (just started
    to learn JQuery and Galleria.js).


    gravatar
    vale
    July 12, 2015 at 4:41 pm

    Solved!
    The problem was that I was retaining the DOM element by using the
    “galleria” prefix. This is how it was supposed to be done:

    this.addElement(‘button-thumbs’);
    var
    $thumbnailsContainer = this.$(‘thumbnails-container’),
    $buttonThumbs = this.$(‘button-thumbs’);

    $buttonThumbs.click(this.proxy(function(e) {
    $thumbnailsContainer.toggleClass(‘toggleme’);
    $buttonThumbs.toggleClass(‘onbutton’); }));
    this.appendChild(‘container’, ‘button-thumbs’);


Galleria.io uses cookies to store information. You can read more about that in our Privacy Policy. I understand