When a page is loaded containing one or more lightgalleries a javascript is triggered:
Uncaught ReferenceError: id is not defined
This causes not initiating the lightgallery for the element.
The error is within the js/lightgallery_load.js file; the variable id is used before being declared.
for (id in settings.lightgallery.instances) {
// Store galleries so that developers can change options.
that.galleries[id] = settings.lightgallery.instances[id];
_lightgallery_init(id, that.galleries[id], context);
}
Adding var before the id fixed the issue:
for (var id in settings.lightgallery.instances) {
// Store galleries so that developers can change options.
that.galleries[id] = settings.lightgallery.instances[id];
_lightgallery_init(id, that.galleries[id], context);
}
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 3028083_6.patch | 787 bytes | mpp |
| #3 | fix_missing_variable_declaration-3028083-3.patch | 573 bytes | zero2one |
Comments
Comment #2
zero2one commentedComment #3
zero2one commentedThis patch fixes the issue.
Comment #4
mpp commentedEvery var counts ;-)
Comment #5
mpp commentedOr you could declare the var before the for structure but that's a matter of taste I assume.
Also fixed a missing newline.
Comment #6
mpp commentedAccording to the javascript coding standards we should put the var in the for structure.
See https://www.drupal.org/docs/develop/standards/javascript/javascript-codi...
Updated patch with the missing newline.
Comment #7
phjouThe patch doesn't seem to apply anymore.
Comment #9
phjou