Why is core.js not loaded in Joomla 3?

1.3k views Asked by At

I am migrating my own Joomla component from Joomla 2.5 to Joomla 3. Some of the buttons use javascript Joomla.submitform(), which was defined in \media\system\js\core.js, but somehow this file is not loaded any more now...

I could simply add JFactory::getDocument()->addScript( JURI::root().'media/system/js/core.js' ) to my component's code, but that seems the quick and dirty way to me.

Could someone tell me what the nice and clean way is? Help is very much appreciated!

2

There are 2 answers

0
Michael On BEST ANSWER

Easy as pie

JHtmlBehaviour::core();
1
RichardB On

It gets added when you use the line JHtml::_('behavior.formvalidator');. This also adds punycode.js and validate.js.

All front-end core components that call submitform() seem to add this in their default.php file.

The following are the places where I found it in the front-end:

  • \components\com_config\view\config\tmpl\default.php
  • \components\com_config\view\modules\tmpl\default.php
  • \components\com_config\view\templates\tmpl\default.php
  • \components\com_content\views\form\tmpl\edit.php