dklemmt / contao_dk_mmenu

Implementation of mmenu as extension for Contao Open Source CMS
15 stars 16 forks source link

Script Error at Internet Explorer 11 with Version 3.x #41

Closed liquid-a closed 4 years ago

liquid-a commented 5 years ago

I have a script Error when i usw the mmenu.js with version 3.0.1 or 3.0.2

The console shows: SCRIPT1002: Syntaxfehler Datei: mmenu.js, Zeile: 1, Spalte: 2278

The menu is not functional with IE 11. No Problems with Firefox or Chrome.

When i use Verison 2.1.1 everything ist O.K.

fritzmg commented 5 years ago

mmenu in general is not compatible with IE 11. There is a PR for automatically including Polyfills though: #40 I'll release it as 3.1.0 today.

Defcon0 commented 5 years ago

The problem here is with

document.addEventListener(
        "DOMContentLoaded", () => {
            new Mmenu('#<?= $this->elementId ?>', <?= json_encode($this->options) ?>, <?= json_encode($this->configuration) ?>);
        },
    );

being the js-template for loading the menu. Why not simply use function() {} instead of () => {} not working in IE11?

Defcon0 commented 5 years ago

Also the trailing comma leads to a syntax error in IE11. So the more compatible version would be:

document.addEventListener(
        "DOMContentLoaded", function() {
            new Mmenu('#<?= $this->elementId ?>', <?= json_encode($this->options) ?>, <?= json_encode($this->configuration) ?>);
        }
    );
fritzmg commented 5 years ago

Yeah, I can optimize this. Also it was a mistake to call the template js_mmenu, as it is not a JavaScript Template that can be included in the page layout.

The code is directly pulled from the documentation of mmenu btw.

operatorone commented 4 years ago

Is it already working in IE11. i just implemented the module and activated the polyfill, but the navigation is jut thrown on the page and the trigger doesn't work.

fritzmg commented 4 years ago

@operatorone the problems mentioned by @Defcon0 have not been fixed yet.

contaoacademy commented 4 years ago

@fritzmg Do you know, when you can fix this?

fritzmg commented 4 years ago

@contaoacademy pls create a justom js_mmenu template and replace

https://github.com/dklemmt/contao_dk_mmenu/blob/3f49fc0f88be06abb4055a3879010170ffcc04a1/src/Resources/contao/templates/js_mmenu.html5#L15-L19

with:

    document.addEventListener(
        "DOMContentLoaded", function() {
            new Mmenu('#<?= $this->elementId ?>', <?= json_encode($this->options) ?>, <?= json_encode($this->configuration) ?>);
        }
    );

If this change works, then I'll change it immediately.

contaoacademy commented 4 years ago

error I get this error

contaoacademy commented 4 years ago

After using the polyfill option the fix works.

fritzmg commented 4 years ago

@contaoacademy pls create a justom js_mmenu template and replace

https://github.com/dklemmt/contao_dk_mmenu/blob/3f49fc0f88be06abb4055a3879010170ffcc04a1/src/Resources/contao/templates/js_mmenu.html5#L15-L19

https://github.com/dklemmt/contao_dk_mmenu/pull/53