A
A
Anton Shelestov2018-05-02 18:28:32
1C-Bitrix
Anton Shelestov, 2018-05-02 18:28:32

How to connect bitrix scripts in the admin panel?

Hello everyone.
I am writing a small module, a problem arose.
On the module page, I connect scripts using the method:

CJSCore::RegisterExt('partner_css_and_js', array(
    'js'  => array(
        '/bitrix/js/partner.module/scripts.js',
    ),
    'css' => array(
        '/bitrix/css/partner.module/jquery.qtip.min.css',
    ),
    'lang' => $rootFolder . '/lang/ru/admin_js.php',
    'rel'  => array('jquery')
));

CJSCore::Init(array("partner_css_and_js"));

Everything connects well, but there was a need to declare the js variable before the included scripts.
<script>
     var adminParams = [...];
</script>

This variable contains an array of generated values.
Tried through $APPLICATION->AddHeadString() but still outputs after connecting the script.
Or how can I move the js connection in the admin panel to the footer?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Nikolaev, 2018-05-02
@gromdron

Don't get hung up on global scope and page execution order.
You are trying to do fully connected things: a variable and a script that works with it, while moving the script into extensions.
If you really want to work with the extension, then use a different paradigm: store classes in the extension js file, and initialize objects with ready-made parameters on the page.
Want to know more? Have a look at the sale.order.ajax or sale.basket.basket components

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question