Forums Forums Search & Filter Pro Split Categories Alphabetically Index

Viewing 2 posts - 1 through 2 (of 2 total)
  • Anonymous
    #53742

    So I actually figured out a way to do that:

    In case anyone has this same question/problem just add this code:

    <script>
    var list = { letters: [] };
    jQuery(".sf-field-category > ul").children("li").each(function(){
      var itmLetter = jQuery(this).text().substring(0,1).toUpperCase();
      if (!(itmLetter in list)) {
        list[itmLetter] = [];
        list.letters.push(itmLetter);
      }
      list[itmLetter].push(jQuery(this));
    });
    list.letters.sort();
    jQuery(".sf-field-category > ul").empty();
    jQuery.each(list.letters, function(i, letter){
      list[letter].sort(function(a, b) {
        return jQuery(a).text().toUpperCase().localeCompare(jQuery(b).text().toUpperCase());
      });
      var ul = jQuery("<ul/>");
      jQuery.each(list[letter], function(idx, itm){
        ul.append(itm);
      });
      jQuery(".sf-field-category > ul").append(jQuery("<li/>").append(jQuery("<label/>").attr("name", letter.toLowerCase()).addClass("title").html(letter)).append(ul));
    });
    </script>
    Trevor
    #53767

    Thanks for sharing. I have tidied up the posts for you 😉

Viewing 2 posts - 1 through 2 (of 2 total)