Vertical menu with filter within the sub-menu

2

I would like to make a filter within the sub-menu, filtering the menu itself as you type is going to display the related ones.

The idea would be similar to this link . At the end of my menu has the sub-menu called store or adm.

Example: link

    
asked by anonymous 06.08.2015 / 18:55

1 answer

1

You can create a filter of this type:

$('#filter').on('keyup', function(){

    var dataFilter = $(this);
    var valorBusca = dataFilter.val();
      var contaLetras = valorBusca.length;
       if (contaLetras >= 1) {
           filterData(valorBusca);
       } else {
        $('.navbar-nav li a').parent().show();  
       }

 function filterData(data) {

        $('.navbar-nav li a').each(function(iIndex, sElement) {
            $(sElement).parent().hide();  
            if (sElement.innerHTML.indexOf(data) !== -1) {
                 $(sElement).parent().show(); 
             }  
        });
} 

function retiraAcentos(palavra) {
    var com_acento = 'áàãâäéèêëíìîïóòõôöúùûüçÁÀÃÂÄÉÈÊËÍÌÎÏÓÒÕÖÔÚÙÛÜÇ';
    var sem_acento = 'aaaaaeeeeiiiiooooouuuucAAAAAEEEEIIIIOOOOOUUUUC';
    var nova='';
    for(i=0;i<palavra.length;i++) {
        if (com_acento.search(palavra.substr(i,1))>=0) {
            nova+=sem_acento.substr(com_acento.search(palavra.substr(i,1)),1);
        }
        else {
            nova+=palavra.substr(i,1);
        }
    }
    return $.trim(nova).toLowerCase();
}

});

Here is JSFiddle: link

Here theme full version: link

    
01.09.2015 / 20:08