Use Drupal.behaviors when implementing javascript

Created on 30 January 2022, almost 3 years ago
Updated 21 March 2024, 9 months ago

Problem/Motivation

When loading extra content with ajax, the ImageLightbox is not applied anymore.

Steps to reproduce

Load extra content using ajax, for example with views_load_more. The images of newly loaded content won't open in the lightbox.

Proposed resolution

Use drupal behaviors when implementing javascript. This is a base rule for all javascript within Drupal. When not using this, you'll lose a bunch of perks that come with the Drupal framework.
See https://www.drupal.org/docs/drupal-apis/javascript-api/javascript-api-overview

🐛 Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

🇧🇪Belgium fernly

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇨🇭Switzerland piridium

    Thank you for the valuable hint. We could use some help with adjusting to Drupal behaviors. Would you be willing to assist us?

  • Status changed to Needs review 9 months ago
  • 🇨🇭Switzerland piridium

    This is a first attempt at implementing Drupal behaviors. Please thoroughly test it and provide feedback on whether it works with Ajax reloading.

Production build 0.71.5 2024