mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
añadido direcciones
This commit is contained in:
@ -1,12 +1,13 @@
|
||||
class ClassSelect2 {
|
||||
|
||||
constructor(domItem, url, placeholder = "", delay = 60, text_field = 'nombre', id_field = 'id') {
|
||||
constructor(domItem, url, placeholder = "", delay = 60, text_field = 'nombre', id_field = 'id', params={}) {
|
||||
this.domItem = domItem;
|
||||
this.url = url;
|
||||
this.placeholder = placeholder;
|
||||
this.delay = delay;
|
||||
this.text_field = text_field;
|
||||
this.id_field = id_field;
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
init() {
|
||||
@ -20,11 +21,17 @@ class ClassSelect2 {
|
||||
dataType: 'json',
|
||||
data: (params) => {
|
||||
|
||||
return {
|
||||
let d = {
|
||||
id: this.id_field,
|
||||
text: this.text_field,
|
||||
searchTerm: params.term,
|
||||
};
|
||||
|
||||
for (let key in this.params) {
|
||||
d[key] = this.params[key];
|
||||
}
|
||||
|
||||
return d;
|
||||
},
|
||||
delay: this.delay,
|
||||
processResults: function (response) {
|
||||
@ -38,6 +45,10 @@ class ClassSelect2 {
|
||||
});
|
||||
}
|
||||
|
||||
setParams(params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
// Método para obtener el valor seleccionado
|
||||
getValue() {
|
||||
return this.domItem.val();
|
||||
@ -48,6 +59,10 @@ class ClassSelect2 {
|
||||
this.domItem.val(value).trigger('change');
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.domItem.val(null).trigger('change');
|
||||
}
|
||||
|
||||
// Método para oculatar el select2
|
||||
hide() {
|
||||
this.domItem.select2('close');
|
||||
|
||||
Reference in New Issue
Block a user