I am trying to use select2 but my function is not detected, the following$('#departamento').on('change', function () {
var data = $(".select2 option:selected").text();
console.log(data);
})
also try the following$('#departamento').on('select2:select', function (e) {
var data = e.params.data;
console.log(data);
});
Hi Jesus,
May I know which Metronic Laravel version are you using?
If it's not the latest, could you please try to get the latest Metronic Laravel version? And then replace these 2 files into your current Laravel project. Please note, if you have modified these files.
resources/assets/core/plugins/plugins.js
webpack.mix.js
Thanks
I use the version Metronic v8.0.35, I don't use the latest version v8.0.36,due to incompatibility, with phpmailer
I have not made any changes to that file.
resources/assets/core/plugins/plugins.js
webpack.mix.js
Hi Jesus,
How's the issue going? Have you tried to update with the latest version? Or at least try to update those 2 files?
Thanks
I already tried to update the files and it didn't work, I'll go to the latest version 3.037, I'll let you know how it goes
select2 js file is not available for angular, you should install it from open source.
Some help
Hi Jesus,
Could you please try to use this HTML markup?
<select class="form-select" name="tag" data-control="select2">
...
console.log($("#departamento"));
if it prints me the console
but my function no longer detects me
, the following code does not work
$(document.querySelector("#kt_ticket_new_form").querySelector("[name="departamento"]")).on("change", (function (event) {
e.revalidateField("departamento");
if (event.target.value.length != 0) {
KTicketMuestraServicios.int();
} else {
KTicketMuestraServicios.limpiar_select_servicio();
document.getElementById("prioridad_int").style.display = "none";
}
}))
require("select2");
Uncaught TypeError: $(...).select2 is not a function
Hi Jesus,
I'm not sure where you have this function in your blade file ,but if it is before
<x-base-layout></x-base-layout>
</x-base-layout>
"YOUR_PAGE_NAME" => array(
"*" => array(
"title" => "YOUR_PAGE_TITLE",
"assets" => array(
"custom" => array(
"js" => array(
"path_to_your_js_file,
),
),
),
),
),
<select class="form-select" data-control="select2" data-placeholder="Select an option">
<option></option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>
What you mention I have already done, I have it as follows
<x-base-layout>
<select class="form-select form-select-solid" data-control="select2" data-allow-clear="true" data-placeholder="{{ __("mensajes.globales.select_placeholder") }}" name="servicio" >
<option></option>
@foreach ($departamentos as $key => $value)
<option value="{{ $value->departamento_id }}">{{ $value->departamento_nombre }}</option>
@endforeach
</select>
</x-base-layout>
"ticket" => array(
"new" => array(
"*" => array(
"title" => "Nuevo ticket",
"assets" => array(
"custom" => array(
"js" => array(
"plugins/custom/ckeditor/ckeditor-document.bundle.js",
"js/custom/ticket/new.js",
),
),
),
),
),
),
Hi Jesus,
Can you explain what this select2 is meant to do? Is it an edit or create form? Is it used for filtering?
I'll need this to better help you fix your problem.
it is used to filter, from what you select it displays information