I have some Galleria displays in views with ajax submit/filters enabled. When returning a new views result Galleria settings are being multiplied.

Seems perhaps the JS is not properly wrapped, or issue resides in the drupal_add_js() call. Also, it may be completely unavoidable from the galleria module side and instead is purely views related. I've solved this by some hacky $.isArray() checking in JS, but this is surely not a desirable solution.

Here are some console.log results from galleria.load.js.

With 2 galleria displays returned by normal page query

console.log(settings.galleria);

instances: Object
  galleria-1: "default"
  galleria-2: "default"
optionsets: Object
  default: Object
    height: 0.7
    preload: 2
    responsive: true
    width: "auto"
themepath: "{site}/sites/all/libraries/galleria/themes/twelve/galleria.twelve.min.js"

And here is the result after being returned by Views Ajax query (this result has 3 galleria items, but the situation is mirrored with any amount):

console.log(settings.galleria);

instances: Object
  galleria-1: "default"
  galleria-2: "default"
  galleria-3: "default"
optionsets: Object
  default: Object
    height: Array[3]
      0: 0.7
      1: 0.7
      2: 0.7
    preload: Array[3]
      0: 2
      1: 2
      2: 2
    responsive: Array[3]
      0: true
      1: true
      2: true
    width: Array[3]
      0: "auto"
      1: "auto"
      2: "auto"
themepath: Array[3]
  0: "{site}/sites/all/libraries/galleria/themes/twelve/galleria.twelve.min.js"
  1: "{site}/sites/all/libraries/galleria/themes/twelve/galleria.twelve.min.js"
  2: "{site}/sites/all/libraries/galleria/themes/twelve/galleria.twelve.min.js"

Cheers,
Alex

CommentFileSizeAuthor
#1 galleria-check_for_ajax_replication.patch757 bytesaschmoe
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

aschmoe’s picture

Here is that "hacky" patch I mentioned in case anyone else is experiencing similar issues with Ajax loads breaking galleria.