0

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!

Herman
  • 361
  • 3
  • 13

2 Answers2

0

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
RichardB
  • 2,615
  • 1
  • 11
  • 14
  • Thanks for your answer. Adding the form validator behavior would still be a kind of dirty work around when I do not need the form validation functionality. In other places, for example in \adminstrator\com_banners\views\banner\tmpl\edit.php, `Joomla.submitform()` is defined in the template file itself by calling `JFactory::getDocument()->addScriptDeclaration()`... :s – Herman Jun 12 '16 at 13:27
0

Easy as pie

JHtmlBehaviour::core();
Michael
  • 9,223
  • 3
  • 25
  • 23