Hi,

I have an ajax view of events listing page. The views have an exposed search on top of the page. The Add to calendar button didn't work after searching. I tried by removing the ajax, then also Add to calendar button is not working.

Thanks in advance for any help.

Comments

sumithb created an issue. See original summary.

guptahemant’s picture

hi @sumithb

Can you please add the screenshots of any issues produced on chrome console or any visible php errors, it would help to easily identify and resolve this error.

Thanks

naresh_bavaskar’s picture

Status: Active » Needs review
StatusFileSize
new760 bytes

Hi
I faced a similar issue on one of my ajax enabled views.
Issue description: addtocalendar.js was not calling after ajax request DOM element.

Attaching a patch to fix the issue.

Please review

Thanks

purushotam.rai’s picture

Probably we would need Drupal behaviors then.

naresh_bavaskar’s picture

StatusFileSize
new736 bytes

Last patch was wrong, thus added the correct patch. Kindly Review

Thanks

purushotam.rai’s picture

LGTM

guptahemant’s picture

Status: Needs review » Fixed

hi @naresh_bavaskar

Thanks for explaining the issue, i was easily able to reproduce it and fix it via the provided patch. Marking this issue as done. keep contributing!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

nightwalkr’s picture

Hi, Added the ajaxSuccess() and validation but not repleat the "atcb-list" in the Add to Calendar.

(function ($) {

  'use strict';

  Drupal.behaviors.addtocalendar = {
    attach: function (context, settings) {
      var load = false;
      $(document).ajaxSuccess(function (event, request, settings) {
        if (!$(".atcb-list", context).length && !load) {
          load = true;
          addtocalendar.load();
        }
      });
    }
  };

})(jQuery);
aswathyajish’s picture

Issue tags: -

Me also had this issue. I was using the version 8.x-3.1.

Now I upgraded the module to the version 8.x-3.2. The patch has been committed to the version 8.x-3.2. And it is working now. Thanks a lot.

yoa’s picture

StatusFileSize
new18.32 KB

Hello,
In the versions that follow the commit of this issue,
I see multiple .atcb-lists added to each date instance: a list is added on every ajax load.
Multiple ul are added
I checked the addtocalendar.js, and there is no check to whether there is already a list attached nor a logical marker to whether the list should be added or not.

Though this issue doesn't cause functional problems, it does cause accessibility problems with keyboard navigation or screenreaders.
I add here a pretty straight forward fix,
I'd be happy if someone with more JS experience can take a look at it or at this issue.

(function ($) {

  'use strict';

  Drupal.behaviors.addtocalendar = {
    attach: function (context, settings) {
      addtocalendar.load();
      $(".atcb-list").next(".atcb-list").remove();
    }
  };

})(jQuery);

And as a side question - why did we create here a jQuery dependency?