Answer the question
In order to leave comments, you need to log in
How to fix BX is not defined for an unlogged user?
Hello.
There is a "form.result.new" component on the page and I need to track the submission of the form, and if the form was submitted, but returned a warning about the incorrect filling of the form fields, I need to scroll the page to the form (to the anchor).
For an authorized user, everything works, but for an unauthorized user, "BX is not defined" is displayed in the console. I thought that something was missing, that it connects with the Bitrix admin panel and began to connect the libraries of Bitrix itself. Connected first
<?
CJSCore::Init(array("ajax"));
?>
, the error in the console disappeared, but the performance was not restored. BX.addCustomEvent('onAjaxSuccess', BX.delegate(function () {
//тут чет происходит
}, this));
Answer the question
In order to leave comments, you need to log in
The fact is that Bitrix does not connect bx_core if no extension is initialized. And you can't connect only core :) connect any of the extensions, for example ajax CUtil::InitJSCore(['ajax']) then core will be connected.
When looking for a solution to this problem, it is also recommended to check the init.php file. There may be a ban on the output of Bitrix core files. Files kernel.main.js, main.core.js, as well as scripts of BX libraries can be prohibited from being displayed for unauthorized users. Such a ban procedure is usually used to speed up the site, but if core files are involved in the functionality on a particular site, it is better not to use a script to block them. In my case, this was the problem.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question