Tell me please! There is a function of a single gallery of the form:

$(function() { Gallery = (function() { // index of the current item var current = 0, // mode : carousel || fullview mode = 'carousel', // control if one image is being loaded anim = false, init = function() { // (not necessary) preloading the images here... $items.add('<img src="/public/images/ajax-loader.gif"/><img src="/public/images/black.png"/>').imagesLoaded( function() { // add options _addViewModes(); // add large image wrapper _addImageWrapper(); // show first image _showImage( $items.eq( current ) ); }); // initialize the carousel _initCarousel(); }; return { init : init}; })(); Gallery.init(); }); 

I need to change the value of the current variable on the onClick () event so that the value is changed before the gallery is initialized. Thank you in advance!

Upd1: Still very interested in how correctly Gallery is called in this case, and how can such pieces be accessed from outside this function and is it even possible?

  • Does anyone not know how this can be done? - makbeth
  • The var current variable is declared inside the function, so you can change it only from the function, so that it is available, globally declare it before the function, and inside remove the var. although maybe you just need to initialize the gallery after onclick, it’s not clear - ffeynmann
  • Actually that's right. Declared a variable globally, then onClick changed its value, and removed both its declaration and value assignment from a function. Now the question remains: how to initialize it after onClick? - makbeth

0