Gallery formatter doesn't work after changing the attribute in product.
For example, when I change the color of the product (ajax) in Drupal Commerce, galerry carousel stops working
I think the problem in the script
What to do?

CommentFileSizeAuthor
Безымянный.png422.54 KBboozenok
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

boozenok’s picture

Issue summary: View changes
IamRokas’s picture

Temporary fix in your js file:

/*Select boxes */
$("body.node-type-product-display .form-type-select select").on('change', function (e) { /* Change selector to fit your select inputs */
setTimeout(function() {
$('.galleryformatter:not(.gallery-processed)', context).each(function(){
Drupal.galleryformatter.prepare(this);
}).addClass('gallery-processed');
}, 5000);
});

Main idea is that you have to listen for changes and initiate the gallery again when new dom is loaded. Without the timeout it doesnt grab it.

illSleepWheniDie’s picture

I'm having the same issue. Very irritating.

marysmech’s picture

I tried IamRokas code with few changed works nice. Thank you very much!

Somebody could find my changes handy:

1) jQuery method on was added in jQuery 1.7. Default Drupal 7 jQuery version (at least my) is 1.4 so just change

$("body.node-type-product-display .form-type-select select").on('change', function (e) {

to

$("body.node-type-product-display .form-type-select select").change(function (e) {

2) I have multiple product variants and code above works just once. If I change variants more than once time code does nothing. To fire code every time I wrapped code to:

Drupal.behaviors.someName = {
    attach: function (context, settings) {
      // here is code above
  }
};

I hope it helps somebody.

ryivhnn’s picture

Used a similar combination of the code in #2 inside a Drupal.behaviors thing like in #4 to "fix" a problem where often-enough-to-be-annoying seemingly randomly the galleryformatter slideshows loading inside a Colorbox Node modal would either be missing thumbnails (which are there in the code and images are findable, just not being rendered) or the main slider image would partially load (nothing wrong with the file, if you use the arrows or the thumbnail slider to navigate away and back it loads, it just freezes up on the initial load).

Getting an ugly flash when the modal loads of all the images being splatted on the page before the magic happens and turns it back into a proper slideshow, I hope that's better than not appearing to load at all though.

Thanks :)

Frays’s picture

I tried #2 and #4 (thank you very much for that !) and get it to work by doing the code below but if I change variants more than once time, code keep open the alert box again and again and does nothing.
Do you have any idea how to fix it?

The site is on kickstart v2.

Drupal.behaviors.someName = {
  attach: function (context, settings) {
    jQuery(".form-item-attributes-field-couleur .form-item input").change(function (e) {
      setTimeout(function() { 
	    alert();
	    jQuery('.galleryformatter:not(.gallery-processed)', context).each(function(){
          Drupal.galleryformatter.prepare(this);
	    }).addClass('gallery-processed');
	  }, 5000);
	});
  }
};
illSleepWheniDie’s picture

#3 illSleepWheniDie commented 4 months ago
I'm having the same issue. Very irritating.

4 Months have passed. I abandoned Drupal for Shopify.
Holy shit!

It took just 4 days to set up a beautiful shopping cart website!!

AND IT WAS FUN!

I had forgotten "fun" in my days of struggling with the ugly Drupal beast!

Regain your sanity friends, go and use Presta shop (free), Shopify, Volusion etc.

ANYTHING BUT DRUPAL. If your boss told you to use Drupal, shoot him!

I'm a genuinely happy man now.
I don't need to code and debug shit-ugly Drupal themes.
My site is up and I focus on business, not debugging Drupal and fighting it's resource consumption problems.

Drupal is "free" in terms of $$, but it is not really because it's very expensive in terms of coding time / skill, debugging time / skill, turnaround time for additions etc. Whatever savings you think you made in money will be eaten up by the hours you sacrifice to the beast. If you're a contractor and you think that's more billable hours, I ask you, how about your credibility? Every time you promise x hrs, but end up with 2x or 3x hours, do you think you have credibility?