user882670
user882670

Reputation:

Disable JS script in Joomla 2.5

I'm using Joomla 2.5.19 and I have removed Mootools since it is generating a conflict with JQuery. I've also disabled caption.js.

Now, on every page, the following script is being added in the head section:

<script type="text/javascript">
window.addEvent('domready', function() {
            $$('.hasTip').each(function(el) {
                var title = el.get('title');
                if (title) {
                    var parts = title.split('::', 2);
                    el.store('tip:title', parts[0]);
                    el.store('tip:text', parts[1]);
                }
            });
            var JTooltips = new Tips($$('.hasTip'), { maxTitleChars: 50, fixed: false});
        });
  </script>

This is throwing the error:

Uncaught TypeError: Object [object global] has no method 'addEvent' 

How do I get rid of this?

I followed the instructions here and deleted:

JHtml::_('behavior.caption');

From components/com_content/controller.php

But no luck. I also tried including unset($this->_scripts['/media/system/js/caption.js']);

How do I get rid of this?

Upvotes: 0

Views: 481

Answers (3)

Brian Bolli
Brian Bolli

Reputation: 1873

If you are developing your own extension there is really no need to remove Mootools or use a third party extension to load jQuery. Mootools is used heavily in Joomla, especially version 2.5.x; so removing it could have adverse affects on expected behavior when using core functions. If you need to use jQuery simply wrap any jQuery code around an IIFE like so:

function($) {

    // jQuery code goes here

})(jQuery);

Upvotes: 0

user882670
user882670

Reputation:

I've managed to remove the script with:

<?php


// Custom script
    $document =& JFactory::getDocument();

    // Remove call to JTooltips
    $document->_script = preg_replace('window\.addEvent\(\'domready\',\s*function\(\)\s*{\s*\$\$\(\'.hasTip\'\).each\(function\(el\)\s*{\s*var\s*title\s*=\s*el.get\(\'title\'\);\s*if\s*\(title\)\s*{\s*var\s*parts\s*=\s*title.split\(\'::\',\s*2\);\s*el.store\(\'tip:title\',\s*parts\[0\]\);\s*el.store\(\'tip:text\',\s*parts\[1\]\);\s*}\s*}\);\s*var\s*JTooltips\s*=\s*new\s*Tips\(\$\$\(\'.hasTip\'\),\s*{\s*maxTitleChars:\s*50,\s*fixed:\s*false}\);\s*}\);', '', $document->_script);


?>

Thanks to this post.

Upvotes: 0

Rahul Kaushik
Rahul Kaushik

Reputation: 1464

You should not remove Mootools, for conflictions, you can use jQuery Easy plugin. Visit http://extensions.joomla.org/extensions/core-enhancements/performance/jquery-scripts/18327

Upvotes: 1

Related Questions