2

How to link jquery files in Joomla 3x to head section. I also downloaded and installed plugin "jQuery++ Integrator by tushev.org", But this is not going to work for me. I am trying this for a image slider. Any help greatly appreciated.

Thanks in Advance

1

1 Answer 1

2

Joomla 3 actually ships with a jQuery version core. Using other jQuery versions likely only generates conflicts. So you should use the one which comes with Joomla whenever possible.

To load it you should use the command JHtmlJquery::framework() (See http://api.joomla.org/cms-3/classes/JHtmlJquery.html#method_framework). This will load it into the head in "noConflict" mode and makes sure it's only loaded once, even when requested by multiple extensions.

In your case, I would use this code:

JHtmlJquery::framework(); 
JHtml::script('com_yourcomponent/jssor.core.js', false, true);
JHtml::script('com_yourcomponent/jssor.utils.js', false, true);
JHtml::script('com_yourcomponent/jssor.slider.js', false, true);
JHtml::script('com_yourcomponent/slide.js', false, true);

Then put your files into following locations:

  • /media/com_yourcomponent/js/jssor.core.js
  • /media/com_yourcomponent/js/jssor.utils.js
  • /media/com_yourcomponent/js/jssor.slider.js
  • /media/com_yourcomponent/js/slide.js

Doing it this way will even allow the template to override specific files if needed. See the excellent blog post from Michael Babker for more details: http://www.babdev.com/blog/139-use-the-media-folder-allow-overridable-media

9
  • Thanks for Reply But this is not working for me. I added Jquery links in header section as below : <?php JHtml::_('jquery.framework'); JHtml::script(JUri::base() . '/js/jquery-1.9.1.min.js', true); JHtml::script(JUri::base() . '/js/jssor.core.js', true); JHtml::script(JUri::base() . '/js/jssor.utils.js', true); JHtml::script(JUri::base() . '/js/jssor.slider.js', true); JHtml::script(JUri::base() . '/js/slide.js', true); ?> Can you please tell me any mistakes here Thanks
    – webanup
    Commented Sep 9, 2014 at 6:17
  • Why are you loading jquery-1.9.1? With this, you're loading two versions of jQuery, the one from core and an own one. Also, are you storing your JS in www.example.com/js/file.js?
    – Bakual
    Commented Sep 9, 2014 at 14:26
  • Can you please suggest me proper syntax for this. Since I don't have any knowledge of Jquery and PHP.
    – webanup
    Commented Sep 10, 2014 at 5:07
  • Added example code
    – Bakual
    Commented Sep 10, 2014 at 10:40
  • 1
    Please, just don't do that. DON'T LOAD YOUR OWN JQUERY VERSION!
    – Bakual
    Commented Sep 15, 2014 at 20:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.