Ho creato una pagina che ha un filtro per la ricerca usando jquery.
Ma penso di aver commesso qualche errore nell'integrazione con gli spoiler.
In pratica mentre si digita nel form vengono trovati in tempo reale il testo digitato, ma non vengono nascosti gli altri risultati (vuoti) contrassegnati dal tag[*]
Qui la pagina con gli errori:
http://nathan4000.altervista.org/test3.html
Questo il codice operativo (ma con errori):
codice:
<script src="jquery.min.js"></script>
<script>
(function ($) {
// custom css expression for a case-insensitive contains()
jQuery.expr[':'].Contains = function(a,i,m){
return (a.textContent || a.innerText || "").toUpperCase().indexOf(m[3].toUpperCase())>=0;
};
function listFilter(header, list) { // header is any element, list is an unordered list
// create and add the filter form to the header
var form = $("<form>").attr({"class":"filterform","action":"#"}),
input = $("<input>").attr({"class":"filterinput","type":"text"});
$(form).append(input).appendTo(header);
$(input)
.change( function () {
var filter = $(this).val();
if(filter) {
// this finds all links in a list that contain the input,
// and hide the ones not containing the input while showing the ones that do
$(list).find("a:not(:Contains(" + filter + "))").parent().slideUp();
$(list).find("a:Contains(" + filter + ")").parent().slideDown();
} else {
// modificando li in div ti permette di espandere tutti gli spoiler - occorre effettuare una ricerca e poi cancellare
$(list).find("li").slideDown();
}
return false;
})
.keyup( function () {
// fire the above change event after every letter
$(this).change();
});
}
//ondomready
$(function () {
listFilter($("#header"), $("#list"));
});
}(jQuery));
</script>