Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught ReferenceError: Contao is not defined #2

Open
sfx12 opened this issue Apr 20, 2021 · 3 comments
Open

Uncaught ReferenceError: Contao is not defined #2

sfx12 opened this issue Apr 20, 2021 · 3 comments

Comments

@sfx12
Copy link

sfx12 commented Apr 20, 2021

Leider Fehlermeldung in der Konsole wie im Titel.

https://www.subdomain.xyz.de/bundles/easyexclude/assets/easyExclude_src.min.js:1

const REQUEST_TOKEN=Contao.request_token;const CONTAO_LOADING="Loading data";var EasyExclude=new Class({Implements:[Options],options:{table:""},fields:null,usergroup:0,checkboxes:{},initialize:function(b){var a=this;this.setOptions(b);$("easyExclude_usergroup").addEvent("change",function(){a.fields=$$("div.easyExclude");a.usergroup=this.get("value");if(a.usergroup>0){a.cleanTheScreen();a.addCheckboxes();a.updateStates()}else{a.cleanTheScreen()}});window.addEvent("subpalette",function(){$("easyExclude_usergroup").fireEvent("change")})},updateStates:function(){var a=this;new Request.JSON({url:window.location.href,data:"isAjax=1&action=easyExcludeGetFieldRights&usergroup="+this.usergroup+"&table="+this.options.table+"&REQUEST_TOKEN="+REQUEST_TOKEN,onRequest:function(){AjaxRequest.displayBox(CONTAO_LOADING+" …")},onComplete:function(){AjaxRequest.hideBox()},onFailure:function(){alert("failed")},onSuccess:function(b,c){if(b.content){b.content.each(function(d){var e="easyExclude_"+d+"_"+a.usergroup;if($(e)){$(e).checked=true}})}a.changeBackgroundColor()}}).send()},addCheckboxes:function(){var a=this;this.fields.each(function(c){var b="easyExclude_"+a.filterForFieldName(c.get("class"))+"_"+a.usergroup;var d=null;if(a.checkboxes[b]){d=a.checkboxes[b]}else{d=new Element("input",{type:"checkbox",name:b,id:b,"class":"tl_checkbox easyExcludeCheckbox",events:{change:function(){a.saveChange(c,this)}}})}d.inject(c,"top")})},saveChange:function(c,e){var a=this;var b=(e.checked)?1:0;var d=new Request.JSON({url:window.location.href,data:"isAjax=1&action=easyExcludeSaveChange&usergroup="+this.usergroup+"&field="+a.filterForFieldName(c.get("class"))+"&table="+this.options.table+"&state="+b+"&REQUEST_TOKEN="+REQUEST_TOKEN,onRequest:function(){AjaxRequest.displayBox(CONTAO_LOADING+" …")},onComplete:function(){AjaxRequest.hideBox()},onFailure:function(){alert("failed")},onSuccess:function(g,f){a.changeBackgroundColor()}}).send()},filterForFieldName:function(b){var a=/easyExcludeFN_([\S]+)/i.exec(b);return a[1]},changeBackgroundColor:function(){$$("input.easyExcludeCheckbox").each(function(b){var a=b.getParent("div.easyExclude");if(b.checked){a.setStyle("background","#E4FFD4")}else{a.setStyle("background","#EBEBEB")}})},cleanTheScreen:function(){$$("input.easyExcludeCheckbox").each(function(b){var a=b.get("id");this.checkboxes[a]=b.dispose()}.bind(this));this.fields.each(function(a){a.setStyle("background","")})}});

CONTAO VER. 4.9
PHP 7.4

@Aybee
Copy link

Aybee commented Mar 17, 2023

Everything fine with PHP 8.1.16 and Contao 4.13.18.

@Aybee
Copy link

Aybee commented Mar 20, 2023

Is that correct that the CSS and JavaScript are also loaded in the FE? The JavaScript actually generates this error in the FE in the console. I guess the JS doesn't belong there, does it?

https://github.com/LinkingYou/contao-easy_exclude/blob/master/src/Backend/EasyExclude.php#L93-L94

I temporarily wrapped those two lines with

if(TL_MODE == 'BE')
{
  // the two lines
}

@Aybee
Copy link

Aybee commented Mar 20, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants