I
I
Ivan Fotiev2016-08-01 19:41:30
JavaScript
Ivan Fotiev, 2016-08-01 19:41:30

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.
Connected ('jquery','ajax', 'window', 'popup').
Here is the code I am trying to catch the form submission
BX.addCustomEvent('onAjaxSuccess', BX.delegate(function () {
//тут чет происходит
    }, this));

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
rinsvent, 2017-03-25
@rinsvent

\CJSCore::Init(); core connection

O
Oleg Maksimenko, 2016-08-01
@olegprof

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.

M
MGA812, 2022-04-15
@MGA812

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 question

Ask a Question

731 491 924 answers to any question