Skip to content

Commit

Permalink
Passage de js à jQuery pour la méthode checkArticleUnicity
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Theuws committed Mar 5, 2021
1 parent 67705ed commit fb407a3
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions tp3/dist/js/article.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,20 @@ class Article {
checkArticleUnicity() {
let h3s = $('.title');

for (let i = 0; i < h3s.length; i++) {
if (h3s[i].innerHTML.toLowerCase().trim() === this.title.toLowerCase().trim()) {
addError('Erreur article deja existant', form);
let this_title = this.title.toLowerCase().trim();

return false;
let retval = true;

h3s.each(function(index){
if ($( this ).html().toLowerCase().trim() === this_title)
{
let form = $('#addNewsForm');
addError('Erreur article déjà existant', form);
return retval = false;
}
}
});

return true;
return retval;
}

checkValue() {
Expand Down

0 comments on commit fb407a3

Please sign in to comment.