Joomla.submitbutton = function(task)

Be informed that this forum is not an official support forum for Joomla! 4.0. Any issues regarding Joomla! 4.0 must be reported at https://issues.joomla.org/.

Joomla 4.0 is still in Beta stage. This forum should be used for sharing information about Joomla! 4.0.
Post Reply
phalouvas
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Mon Jul 06, 2020 12:40 pm

Joomla.submitbutton = function(task)

Post by phalouvas » Tue Jul 07, 2020 4:45 am

Hello,

I am trying to upgrade my extensions but I am puzzled about the front end form validation. Currently in my tmpl file I use
Joomla.submitbutton = function(task) {
bla bla bla
}

All I get when loading page is:
Uncaught ReferenceError: Joomla is not defined

Any directions how to replace this? Practically I try to override the default submition.

Thanks in advance for any tips.

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 13261
Joined: Thu Feb 15, 2007 5:48 am
Location: Zagreb, Croatia

Re: Joomla.submitbutton = function(task)

Post by toivo » Tue Jul 21, 2020 6:16 am

The following tutorial shows how to configure the validation of input forms: Client-side Form Validation
Toivo Talikka, Global Moderator

SharkyKZ
Joomla! Ace
Joomla! Ace
Posts: 1840
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: Joomla.submitbutton = function(task)

Post by SharkyKZ » Tue Jul 21, 2020 7:50 am

Load core.js script:

Code: Select all

Joomla\CMS\HTML\HTMLHelper::_('behavior.core');

User avatar
garkell
Joomla! Apprentice
Joomla! Apprentice
Posts: 42
Joined: Mon Aug 31, 2009 9:32 pm
Location: Australia
Contact:

Re: Joomla.submitbutton = function(task)

Post by garkell » Sun Dec 27, 2020 4:36 am

@SharkyKZ - so in my tmpl file I have the behavior for core and then display a button with task like this:

Code: Select all

HTMLHelper::_('behavior.core');
 . . .
<button type="button" class="btn btn-secondary" onclick="Joomla.submitbutton('attendance.cancel')">
	<span class="icon-undo" aria-hidden="true"></span>
	<?php echo Text::_('COM_MYCOMPONENT_RETURN'); ?>
</button>
and by clicking this return button will take me to the controller task called cancel?
Well it doesn't so what am I missing? All help appreciated. Cheers.
Glenn

User avatar
ceford
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 165
Joined: Mon Feb 24, 2014 10:38 pm
Location: Edinburgh, Scotland
Contact:

Re: Joomla.submitbutton = function(task)

Post by ceford » Sun Dec 27, 2020 6:42 pm

I don't do much with front-end buttons so I am not sure if this is quite right. But, taking the login form as an example, the foot of the form contains:

Code: Select all

<input type="hidden" name="task" value="user.login">
And the Login button is just a submit button. So try putting that field at the foot of your form with controller.task in the value field (looks like attendance.cancelled in this case). Then use a submit (primary button) to submit the form. You may need to use some custom javascript to insert the value if it is not decided when the page is loaded.


Post Reply

Return to “Joomla! 4 Related”