diff --git a/kfet/templates/kfet/kpsul.html b/kfet/templates/kfet/kpsul.html index aab04abe..86bb48fa 100644 --- a/kfet/templates/kfet/kpsul.html +++ b/kfet/templates/kfet/kpsul.html @@ -526,16 +526,14 @@ $(document).ready(function() { }); if (!added) articles_container.append(category_html); } - var added = false; + var $after = articles_container.find('#data-category-'+article['category_id']); articles_container .find('.article.data-category-'+article['category_id']).each(function() { - if (article['name'].toLowerCase < $('.name', this).text().toLowerCase()) { - $(this).before(article_html); - added = true; + if (article['name'].toLowerCase < $('.name', this).text().toLowerCase()) 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 articlesList.push([article['name'],article['id'],article['category_id'],article['price']]); }