Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reload GalleryView With New Image Set #27

Open
azinyama opened this issue Jul 12, 2012 · 1 comment
Open

Reload GalleryView With New Image Set #27

azinyama opened this issue Jul 12, 2012 · 1 comment

Comments

@azinyama
Copy link

Good day!!!

I wanted to find out if it would be possible to do the following:
Start with -

ul
li. img src="imagesset1/1.jpg" /li.
li. img src="imagesset1/2.jpg" /li.
li. img src="imagesset1/3.jpg" /li.
/ul.

Then use jQuery to change dynamically change the image 'src' to a different image set, say 'imagesset2' -
ul.
li. img src="imagesset2/1.jpg" /li.
li. img src="imagesset2/2.jpg" /li.
li. img src="imagesset2/3.jpg" /li.
/ul.

Then reload GalleryView to show the new images

Thanx in advance

@azinyama
Copy link
Author

Came up with a solution. It works but I don't know how correct the code is:

//CHANGE GALLERY IMAGE SRC DYNAMICALLY

    $('#gallery ul li a').live('click', function(e)
    {
        e.preventDefault();

        var $clicked = $(this);
        var $current = $('.sub_current');

        if (!$clicked.hasClass('sub_current'))
        {
            //CHANGE IMAGE SRC              
            ourGallery.find('img').each(function()
            {
                $(this).attr('src', $(this).attr('src').replace($current.attr('href').split('#')[1], $clicked.attr('href').split('#')[1]));
            }); 
            //RELOAD GALLERY FUNCTION
            ourGallery.galleryViewReload(
            {
                panel_width: 788,
                panel_height: 390,
                show_infobar: false,
                enable_overlays: false,
                show_captions: false,
                panel_animation: 'crossfade'
            });
        }
    });

//THEN IN GalleryView ADD

,

    reloadGallery: function() {
        var self = this,
            dom = this.dom;

        // convert source images into gvImage objects
        this.storeImages();

        // begin loading images into gallery
        this.initImages();

        // show gallery
        dom.gv_galleryWrap.show();

        if(this.opts.autoplay) {
            this.startSlideshow(true);
        }

        this.updateOverlay(this.iterator);
        this.updateFilmstrip(this.frameIterator);
    }

//THEN ADD

/*
MAIN PLUGIN CODE
*/
$.fn.galleryView = function (options) {
if (this.length) {
return this.each(function () {
var gallery = Object.create(GalleryView);
gallery.init(options,this);

            $.fn.galleryViewObj(gallery);
        });
    }
};

var galleryobj;

$.fn.galleryViewObj = function (obj) {
    galleryobj = obj;
};

$.fn.galleryViewReload = function (options) {
    galleryobj.reloadGallery(options,this);
};

@azinyama azinyama reopened this Jul 14, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant