I added custom attributes for customer which are combo boxes and it is good.
I want change list of combo box 2(Rights), when I select an option from combo box 1(Role).
I added a javascript code as below but it doesn't catch event.
I guess I put js codes in a wrong position. Please tell me where is the correct position.
VENDOR/MODULE/view/adminhtml/layout/customer_index_edit.xml
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="Shooga\DealerAccess\Block\DealerAccess" template="Shooga_DealerAccess::js.phtml" after="customer_form"/>
</referenceContainer>
</body>
</page><script type="text/javascript">
require([
'jquery'
], function($){
$(document).ready(function(){
alert('Yes.. It works..!!!');
$('select[name="customer[role]"').on('change', function() {
alert('Select');
});
});
});
</script>
Solved! Go to Solution.
I soved the problem.
I used $(document).ajaxComplete instead of $(document).ready.
<script type="text/javascript">
require(['jquery', 'domReady!'], function($) {
'use strict';
$(document).ajaxComplete(function( event, xhr, settings ) {
$('select[name="customer[role]"').on('change', function() {
alert('ds');
});
});
});
</script>
I soved the problem.
I used $(document).ajaxComplete instead of $(document).ready.
<script type="text/javascript">
require(['jquery', 'domReady!'], function($) {
'use strict';
$(document).ajaxComplete(function( event, xhr, settings ) {
$('select[name="customer[role]"').on('change', function() {
alert('ds');
});
});
});
</script>