DirkPersky / typo3-dp_cookieconsent

TYPO3 Extension: Enable a cookie consent box. Let you visitors control the usage of cookies and load script or content after a consent. (ePrivacy, TTDSG)
GNU Affero General Public License v3.0
32 stars 27 forks source link

Fire Event: cannot access e.detail$el #110

Closed christophbee closed 1 year ago

christophbee commented 1 year ago

TYPO3 11.5.22 dp_cookieconsent 11.6.3

I try to execute a js script after accepting the cookie "thirdparty". Therefore I include the following snippet:

<script data-ignore="1" 
        data-cookieconsent="thirdparty" 
        async=true 
        id="my-iframe"
        class='a-css-class' 
        type='text/plain' 
        data-src='[src url]></script>

After accepting the appropriate cookie "thirdparty" I want to catch the event 'dp--cookie-fire'. Documentation:

document.addEventListener('dp--cookie-fire', function (e) {
    console.log('dp--cookie-fire', e.detail.$el);
});

My implementation

document.addEventListener('dp--cookie-fire', function (e) {
    var el2 = jQuery(e.detail.$el);
    if(el2.hasClass(IFRAME_CLASS)) {
        // do some stuff
    }
});

My code is executed after accepting the cookie but e.detail is null and therefore it throws an error in this line: var el2 = jQuery(e.detail.$el);

Bildschirm­foto 2023-02-12 um 08 05 07

The event that is fired looks like this:

Bildschirm­foto 2023-02-12 um 08 48 56

Anyone an idea where the problem may be? Thx

christophbee commented 1 year ago

@DirkPersky I just tried to use the updated JS file but this leads to an "unexpected end of input" error in my developer console. Bildschirm­foto 2023-03-08 um 16 29 38 Bildschirm­foto 2023-03-08 um 16 30 06

As a result I tried to validate the javascript of the file and it shows an error as well, see screenshot. Bildschirm­foto 2023-03-08 um 16 27 17 I used this validator: https://codebeautify.org/jsvalidate

Can you reproduce this error and/or check this again, please?

DirkPersky commented 1 year ago

Your first screen more looks like u haven't completed uploaded the Script.

I have it on my private site "https://dp-wired.de/" and there the subscriber works.

image

christophbee commented 1 year ago

You were right, we were faced with some permission issues when uploading the files via FTP. Now all works fine, thx!