$ document-> addScript does not work

I have the appearance of a component that should include a .js file in the header (the header is created by Joomla, and not hardcoded in default.php). Frontend file - mysite.com/components/com_arrcard/views/tmpl/default.php; The javascript file is located at mysite.com/administrator/components/com_arrcard/js/CalendarPopup.js.

Here is what I tried in my default.php:

$document =& JFactory::getDocument();
$popUrl = JURI::root(true).'/website/documents/ccv.html';
$popImage = JURI::root(true).'/website/documents/cv_card.jpg';
$popPhone = JURI::root(true).'/website/documents/phone.html';

$document->addScript( JURI::root(true).'/administrator/components/com_arrcard/js/CalendarPopup.js' );

The variables $ popImage and $ popPhone are set correctly, but the script is not added - when I look at the displayed source of the page, CalendarPopup.js is nowhere.

Can anyone help me out? What am I doing wrong here? I also tried

$document->addScript('administrator/components/com_arrcard/js/CalendarPopup.js' );

. addScript , com_arrark . , addScript?

+3
2

. , , - JS, CSS ( - , css include).

JHTML::script( 'javascript.js', 'components' . DS . 'com_component' . DS . 'lib' . DS . 'js' . DS );
JHTML::stylesheet( 'style.css', 'components' . DS . 'com_component' . DS . 'lib' . DS . 'css' . DS );

, DS ( ), Joomla /\ , .

, :

JHTML::script( 'CalendarPopup.js', 'administrator' . DS . 'components'. DS .'com_arrcard'. DS .'js');
+2

, , . JDocument , ​​, , , ( MVC).

, index.php :

, ( , ), .. .

, rhuk_milkyway, , .

0

Source: https://habr.com/ru/post/1775256/