arreglado los select2 para que funcionen con el select2 de alvaro

This commit is contained in:
2024-10-14 14:29:43 +02:00
parent 44fc60372b
commit 9c3a7848f3
4 changed files with 37 additions and 6 deletions

View File

@ -4,9 +4,11 @@
* @param {String} url
* @param {String} placeholder
*/
let ClassSelect = function (domItem, url, placeholder, allowClear = false) {
let ClassSelect = function (domItem, url, placeholder, allowClear = false, params = {}) {
this.url = url;
this.item = domItem;
this.params = params;
this.config = {
placeholder: placeholder,
allowClear: allowClear,
@ -15,10 +17,14 @@ let ClassSelect = function (domItem, url, placeholder, allowClear = false) {
url: () => {
return this.url;
},
data: function (params) {
return {
q: $.trim(params.term),
};
data: (params) => {
let d = $.trim(params.term);
for (let key in this.params) {
d[key] = this.params[key];
}
return d;
},
processResults: function (data) {
return {

View File

@ -10,7 +10,7 @@ class DatosGenerales {
this.validatorStepper = validatorStepper;
this.formatoLibro = new ClassSelect($("#papelFormatoId"), '/papel-formato/menuitems', window.translations["formatoLibro"]);
this.cliente = new ClassSelect($("#clienteId"), '/clientes/cliente/menuitems', window.translations["selectCliente"]);
this.cliente = new ClassSelect($("#clienteId"), '/clientes/cliente/getSelect2', window.translations["selectCliente"]);
this.titulo = this.domItem.find("#titulo");