-1

I have a view in Drupal 8 with an exposed form with AJAX enabled. It works fine for admin user, but it doesn't for anonymous users.

I have included in my theme libraries file:

dependencies:
  - core/drupal.ajax

But it's still not working.

closed as unclear what you're asking by Kevin, Pierre.Vriens, leymannx, mradcliffe, sanzante Jul 2 at 8:45

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • What does the Ajax call return for anonymous users? You can use your browser's inspect tool / networking tab to see ajax calls from the page and their results. – CG Monroe Jun 25 at 17:15
  • Instead of making an Ajax call, the submit button reloads the page with the view filtered. – jmzea Jun 25 at 18:14
  • Any console errors? I think I've seen this before when other js issues are present – Mrweiner Jun 26 at 1:46
  • No, no errors in the console. – jmzea Jun 26 at 6:21
0

Solved.

The problem was that I had a template file for html.html.twig, where the main content was being wrapped in two divs. The problem was that the code

<js-bottom-placeholder token="{{ placeholder_token|raw }}">

was being wrapped too making the AJAX fail, although I don't know why only for users that were not administrators.

Moving this piece of code to the bottom, just before the closing tag for the body, solves it and everything works fine.

Not the answer you're looking for? Browse other questions tagged or ask your own question.