Clean JS ajout article et ordre des articles

This commit is contained in:
Aurélien Delobelle 2016-09-06 16:38:48 +02:00
parent e154316eae
commit 1f61f79606

View file

@ -526,16 +526,14 @@ $(document).ready(function() {
}); });
if (!added) articles_container.append(category_html); if (!added) articles_container.append(category_html);
} }
var added = false; var $after = articles_container.find('#data-category-'+article['category_id']);
articles_container articles_container
.find('.article.data-category-'+article['category_id']).each(function() { .find('.article.data-category-'+article['category_id']).each(function() {
if (article['name'].toLowerCase < $('.name', this).text().toLowerCase()) { if (article['name'].toLowerCase < $('.name', this).text().toLowerCase())
$(this).before(article_html);
added = true;
return false; return false;
} $after = $(this);
}); });
if (!added) articles_container.find('#data-category-'+article['category_id']).after(article_html); $after.after(article_html);
// Pour l'autocomplétion // Pour l'autocomplétion
articlesList.push([article['name'],article['id'],article['category_id'],article['price']]); articlesList.push([article['name'],article['id'],article['category_id'],article['price']]);
} }