User tests: Successful: Unsuccessful:
Pull Request for Issue #20853 .
Make it possible to use onclick
and onchange
event in joomla-field-switcher
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.
Onclick event and Onchange event are added to the field "Search Engine Friendly URLs". The Event you inserted in autom template is triggert.
Nothing changed. No attribut is added to the joomla-field-switcher. No event is triggert. You see the alert.
Status | New | ⇒ | Pending |
Category | ⇒ | Layout |
Close as merged in backend templat: joomla/40-backend-template#446
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-07-15 07:04:05 |
Closed_By | ⇒ | astridx | |
Labels |
Added:
?
|
Because I do not know where the right place for the pr is:
See joomla/40-backend-template#446