Hi !
I'm using select element with data-kt-select2="true" , but when I declare on change event in my page KTUtil.onDOMContentLoaded , the event will not be trigger . Anyone know how to fix it ? (I'm using metronic laravel template and use laravel mix).
This is my html and js code :
<select class="form-select form-select-solid fw-bolder" id="birthdate_y" name="birthdate_y" data-kt-select2="true" data-allow-clear="true" data-hide-search="true" >
<option value=""></option>
<option value="1">1</option>
</select>
KTUtil.onDOMContentLoaded(function () {
$("#birthdate_y").on("change", function(){
console.log("in");
});
});
Hi,
Please try to use the Select Event API as shown below:
$("#mySelect2").on("select2:select", function (e) {
// Do something
});
still the same ... not working ...
but when i declare in the resources/assets/extended/js/layout/app.js
line: 420
KTUtil.onDOMContentLoaded(function() {
KTApp.init();
$("#birthdate_y").on("change", function(){
console.log("in");
});
});
Hi,
Please make sure that the script you declared the code in is loaded on your page after other theme scripts. If you need any further help can u please provide a test link to your page ?
Regard.
Sorry test link not yet created, but i'm sure the code is loaded, thanks for your help.
I'm using scripts.bundle.js and plugins.bundle.js in metronic html template instead , and all event can work normally, but in this way I can't use mix js , it's a little pity , but the project is in a hurry , so I use this solution first , maybe someday go back to figure the question out .
Hi,
Noted, all the best with your project.
When you have time please have a look at using build tools and editing the code from the src
folder and get it compiled to assets
folder. Nowadays the building tools are key for rapid and efficient development.
For more info about using Metronic please check the Theme Documentation
and Video Tutorials
Regards.