Commit bc92bfb9 authored by Mat's avatar Mat

OffreLegumes et LettreInfos, sortForm listener seulement s'il existe

parent c1d9c5f7
......@@ -121,7 +121,6 @@
let id_lettre = {{ id }};
let sortForm = document.querySelector('form[name=lettre_sorted]');
let input = sortForm.querySelector('input#lettre_sorted_sorted');
{% include '@Potage/LettreInfos/ajaxDisplay.js' %}
{% include '@Potage/Lettre/dateSlider.js' %}
......
......@@ -56,8 +56,9 @@ reloadButton(function(){ reloadGridInfos(); });
* Un form 'sorted' affiche en console
* un tableau avec l'ordre souhaité
*/
sortForm.addEventListener('submit', function(e)
{
if (sortForm) {
sortForm.addEventListener('submit', function(e)
{
let list = [];
let items = document.querySelectorAll('.ui-state-default');
for (let i=0; i < items.length; i++)
......@@ -65,6 +66,8 @@ sortForm.addEventListener('submit', function(e)
list[i] = items[i].dataset.infoId;
}
console.log(list);
let input = sortForm.querySelector('input#lettre_sorted_sorted');
input.value = list;
let form = this;
......@@ -79,7 +82,8 @@ sortForm.addEventListener('submit', function(e)
},
form
);
});
});
}
/*
......
......@@ -133,7 +133,6 @@
let id_offre = {{ id }};
let sortForm = document.querySelector('form[name=offre_sorted]');
let input = document.querySelector('input#offre_sorted_sorted');
{% include '@Potage/OffreLegumes/ajaxDisplay.js' %}
......
......@@ -95,9 +95,9 @@ reloadButton(function(){ reloadGridLegumes(); });
* Un form 'sorted' affiche en console
* un tableau avec l'ordre souhaité
*/
sortForm.addEventListener('submit', function(e)
{
if (sortForm) {
sortForm.addEventListener('submit', function(e)
{
let list = [];
let items = document.querySelectorAll('.ui-state-default');
for (let i=0; i < items.length; i++)
......@@ -105,6 +105,7 @@ sortForm.addEventListener('submit', function(e)
list[i] = items[i].dataset.legumeId;
}
let input = document.querySelector('input#offre_sorted_sorted');
input.value = list;
let form = this;
......@@ -119,7 +120,8 @@ sortForm.addEventListener('submit', function(e)
},
form
);
});
});
}
/*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment