Search code examples
jqueryjquery-pluginsgalleriffic

Galleriffic plugin extra spaces


I'm using the jquery Galleriffic plugin, here is part of the code that is generated by the script :

    <div id="slideshow" class="slideshow">
<span class="image-wrapper current" style="opacity: 1; ">
<a class="advance-link" rel="history" href="#2" title="Title #0">
&nbsp;<img alt="Title #0" src="images/products/Classic.jpg"></a></span></div>

This space before the img tag is causing the image to display in the wrong place, I dont know why the script generates such space, but I thought I should remove the space instead.

I tried the following code, but it didnt work.

$('a.advance-link').text( $('a.advance-link').text().replace(/\s+/g, "") );

I also tried this one

$('a.advance-link:contains("&nbsp;")').html(function(i, h) {
                        return h.replace(/\s+/g, '');
                      });

but no luck, can somebody figure out how would i remove it ?

Thanks


Solution

  • Took a look at the plugin.

    // Construct new hidden span for the image
    var newSlide = this.$imageContainer
    .append('<span class="image-wrapper current"><a class="advance-link" rel="history" href="#'+this.data[nextIndex].hash+'" title="'+imageData.title+'">&nbsp;</a></span>')
    .find('span.current').css('opacity', '0');
    
    newSlide.find('a')
        .append(imageData.image)
        .click(function(e) {
            gallery.clickHandler(e, this);
    });
    

    You'll notice that it first constructs the string you're talking about, then it appends the imageData into the anchor. The result is that the &nbsp; tag is never replaced. You could try simply changing that .append(imageData.image) to .html(imageData.image) and seeing if that doesn't fix your issue.