Hello :)

I classified it as a feature request because it could be better way of solving it :) And compatibility among modules in Drupal... Any tip is very welcome to solve it better!

Problem/Motivation

I am building a site that all loads in the home page with Ajax. I am using the Ajaxify Drupal with JQuery Ajax module with your distribution. I have a Panel page using Panopoly accordion. Each accordion panel has a minipanel with a views list of nodes. When I load a node through Ajax, all the libraries are loaded for that container and I get this error.

Error: cannot call methods on accordion prior to initialization; attempted to call method 'refresh'

Proposed resolution

When I check for initialization, the problem is gone :)
So I changed


        if (jQuery('#'+region_id).hasClass("ui-accordion")) {
            jQuery('#'+region_id).accordion("refresh");
        } else {
          jQuery('#'+region_id).accordion(accordion.options);
        }

to


        if (jQuery('#'+region_id).hasClass("ui-accordion")) {
          if($(this).attr('data-active')){
            jQuery('#'+region_id).accordion("refresh");
          }
        } else {
          jQuery('#'+region_id).accordion(accordion.options);
        }

I tested also patch 8 in #2777847: Unable to have multiple accordions on a single page, but it didn't solved the problem, since there the accordions are initialized.

Patch in comment #2

Also, I think that Ajaxify Drupal with JQuery Ajax module is user-friendly as your distribution and users from Panopoly can be trying it to solve Ajax.

Interesting module panopoly_theme, by the way :) Learning a lot from you as always :)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

candelas created an issue. See original summary.

candelas’s picture

dsnopek’s picture

Hm. Wouldn't that prevent the initialization of the accordion? It seems like this test should be part the existing if so that the else that initializes the accordion should be activated. That said, I haven't actually tested it, just looked at the patch.

In any case, thanks for the contribution!

candelas’s picture

I have only one accordion but when Ajaxify Drupal with JQuery Ajax module loads a page inside the accordion I get that error. It reloads all the libraries and because of the #ids it JQuery gets confused. Because that I put $(this). Maybe a better solution it would be to add $(this) to all and then we don't need the 2 if. Thanks for your time :)