Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.0] Onclick and Onchange in joomla-field-switcher #20931

Closed
wants to merge 2 commits into from

Conversation

astridx
Copy link
Contributor

@astridx astridx commented Jun 29, 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

@astridx
Copy link
Contributor Author

astridx commented Jun 29, 2018

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

@astridx
Copy link
Contributor Author

astridx commented Jul 15, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants