? Pending

User tests: Successful: Unsuccessful:

avatar astridx
astridx
29 Jun 2018

Pull Request for Issue #20853 .

Summary of Changes

Make it possible to use onclick and onchange event in joomla-field-switcher

Testing Instructions

Open global configuration and see outer html of the field "Search Engine Friendly URLs"


<joomla-field-switcher id="jform_sef" off-text="No" on-text="Yes" type="success">
<span class="switcher active has-success" tabindex="0" aria-checked="true" role="switch" aria-label="Yes"><input id="jform_sef0" name="jform[sef]" value="0" tabindex="-1" class="valid form-control-success" aria-invalid="false" type="radio"><input id="jform_sef1" name="jform[sef]" value="1" class="valid active form-control-success" tabindex="-1" checked="" aria-invalid="false" type="radio"><span class="switch"></span></span><span class="switcher-labels"><span class="switcher-label-0">No</span><span class="switcher-label-1 active">Yes</span></span></joomla-field-switcher>

Open /administrator/components/com_config/forms/application.xml

and change the field (insert onclick and onchange`)

		<field
			name="sef"
			type="radio"
			label="COM_CONFIG_FIELD_SEF_URL_LABEL"
			class="switcher"
			default="1"
			filter="boolean"
			>
			<option value="0">JNO</option>
			<option value="1">JYES</option>
		</field>

to

		<field
			name="sef"
			type="radio"
			label="COM_CONFIG_FIELD_SEF_URL_LABEL"
			class="switcher"
			default="1"
			filter="boolean"
			onclick="MyOnclickEvent"
			onchange="MyOnchangeEvent"
			>
			<option value="0">JNO</option>
			<option value="1">JYES</option>
		</field>

Add the function for triggering the events. For example: Open the file /administrator/templates/atum/index.php and change the text

<head>
	<jdoc:include type="metas" />
	<jdoc:include type="styles" />
	<jdoc:include type="scripts" />
</head>

to


<head>
	<jdoc:include type="metas" />
	<jdoc:include type="styles" />
	<jdoc:include type="scripts" />
	<script>
		function MyOnclickEvent(){
			alert('click');
		};
		function MyOnchangeEvent(){
			alert('change');
		};
	</script>
</head>

Open again global configuration and see outer html of the field "Search Engine Friendly URLs". No the attributes are added. If you click on the field "Search Engine Friendly URLs" the events onclick and onchange are triggert. You see the alerts.

Expected result

Onclick event and Onchange event are added to the field "Search Engine Friendly URLs". The Event you inserted in autom template is triggert.

Actual result

Nothing changed. No attribut is added to the joomla-field-switcher. No event is triggert. You see the alert.

Documentation Changes Required

avatar astridx astridx - open - 29 Jun 2018
avatar astridx astridx - change - 29 Jun 2018
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 29 Jun 2018
Category Layout
avatar astridx
astridx - comment - 29 Jun 2018

Because I do not know where the right place for the pr is:
See joomla/40-backend-template#446

avatar astridx
astridx - comment - 15 Jul 2018

Close as merged in backend templat: joomla/40-backend-template#446

avatar astridx astridx - change - 15 Jul 2018
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2018-07-15 07:04:05
Closed_By astridx
Labels Added: ?
avatar astridx astridx - close - 15 Jul 2018

Add a Comment

Login with GitHub to post a comment