A
A
Alexey Nikolaev2014-09-10 20:16:59
CMS
Alexey Nikolaev, 2014-09-10 20:16:59

How to add a script to the document after the already defined ones in the Joomla component?

The essence of the problem is as follows. Usually in CMS and frameworks it is possible to add a script or other file to the head block through special functions, which are then passed to the core, and Joomla also has this - this is addScript (). It works almost perfectly, if not for one "but": when I try to add a script in my own component (I do it in view.html.php, i.e. in the view controller), it is added on top of all the standard ones. In other words, the script is connected before all libraries are connected, and it does not work. I suspect that this is due to the fact that the execution of such expressions starts "from the bottom", from the depths, and not "from above" - ​​from the main template file.
Actually, the question is obvious. Is it possible to somehow connect your script in your own component in such a way,already added before in other places?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Romanov, 2014-09-12
@Heian

Scripts are connected in the same order in which they are called. Where in view.html.php do you include them? Just in a file before the class definition or in the display method? If it's just in a file, then the connection will occur when the view file is loaded by Joomla. It is early. It is necessary in the display method, it will work when other scripts are already immersed.
Also, if it comes from jQuery, then you can simply call
or
Before including your scripts.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question