views:

13

answers:

1

Hi, I'm using the Superfish jquery plugin and its fine. But I've got a menu with *many" voices (at least 300) and I'm wondering if there is a way to put some text field and filter the menu voices basing on what the user write.

Like this (http://jsearchdropdown.sourceforge.net/)... but this one looks pretty ugly!

Regards, Segolas

A: 

Solved. My code search inside a large html table, which contains email related fields, and add and remove elements to the menu based on what the user types in the input text field.

Javascript code:

$(function(){
$('#msgIndexUL').superfish();

$("#menuFilterTextField").keyup(function(){         
    $("#msgIndex li:not('#menuFilter')").empty();

    var id;
    var mailSubject;
    $(".results tbody tr").filter(":contains('"+ $("#menuFilterTextField").val() +"')").each(function(){        
        id = $(this).attr('id');
        mailSubject = $($(this).children(".mailSubject")).html();       
        $("#msgIndex").append("<li><a href='#"+id+"'>"+mailSubject+"</a></li>");                            

    });                         
});

});

And the html:

<ul id="msgIndexUL" class="sf-menu">
                <li class="current">
                    <a href="##">Indice dei messaggi</a>
                    <ul id="msgIndex">
                        <li id="menuFilter"><input type="text" id="menuFilterTextField"/></li>
                    </ul>               
                </li>
</ul>
Segolas