K
K
kimsasha2020-07-14 08:44:30
1C-Bitrix
kimsasha, 2020-07-14 08:44:30

Where to register the call to the BX.SidePanel.Instance.bindAnchors method?

Good afternoon!

The documentation https://dev.1c-bitrix.ru/api_help/js_lib/sidepanel... says "If you want to process links on all pages of the site, the BX.SidePanel.Instance.bindAnchors call must be moved to the site template."

Where to write the method call itself if it is forbidden to customize the bitrix24 template?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Nikolaev, 2020-07-14
@kimsasha

1) Subscribe to the OnEpilog event of the main module.
More details in the documentation: https://dev.1c-bitrix.ru/learning/course/index.php...
Why onEpilog? Because the main code of the page has already been executed, and the buffering has not yet finished.
2) On the event:
- Check that this is not an Ajax request
$req = \Bitrix\Main\Application::getInstance()->getContext()->getRequest();
// $req->isAjaxRequest()
- Check that the page is not an admin panel (the ADMIN_SECTION constant will be defined and it will be true)
And if ok, then register and include our js library and include it.
More about js libraries: https://dev.1c-bitrix.ru/api_help/js_lib/my_extens...
3) We register a subscription in the code of our library, as you indicated

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question