Retrieve old values when unchecking "no book for this class".

This commit is contained in:
Gabriel Augendre 2018-06-02 09:59:15 +02:00
parent 78cb528fe7
commit 601179eba5

View file

@ -1,6 +1,14 @@
document.addEventListener("DOMContentLoaded", function (event) {
var _selector = document.querySelector('#id_no_book');
if (_selector === null) return;
var data = {
title: document.querySelector('#id_title').value,
authors: document.querySelector('#id_authors').value,
publicationYear: document.querySelector('#id_publication_year').value,
isbn: document.querySelector('#id_isbn').value,
price: document.querySelector('#id_price').value,
editor: document.querySelector('#id_editor').value,
};
_selector.addEventListener('change', function (event) {
if (_selector.checked) {
document.querySelector('#id_title').value = "PAS DE LIVRE POUR CETTE CLASSE";
@ -19,12 +27,12 @@ document.addEventListener("DOMContentLoaded", function (event) {
}
document.querySelector('#id_editor').value = editorValue;
} else {
document.querySelector('#id_title').value = "";
document.querySelector('#id_authors').value = "";
document.querySelector('#id_editor').value = "";
document.querySelector('#id_publication_year').value = "";
document.querySelector('#id_isbn').value = "";
document.querySelector('#id_price').value = "";
document.querySelector('#id_title').value = data.title;
document.querySelector('#id_authors').value = data.authors;
document.querySelector('#id_editor').value = data.editor;
document.querySelector('#id_publication_year').value = data.publicationYear;
document.querySelector('#id_isbn').value = data.isbn;
document.querySelector('#id_price').value = data.price;
}
});
});