I have tried all kinds of lists I found all over the internet, but none of them seem to properly work. I think te reason for this might be the fact that the content of the list is dynamiccally loaded (with jquery ajax).
On $(document).ready I load the list and append the html data to the div.
After that I try to make the list collapsible (the list is nested, it's a navigation for a database).
My best try so far:
$(document).ready(function(){
loadnavigation(); //to load the li items//
fold();
})
function fold(){
function fold1(){
$("#container").on("click", "#nav > li", function(){
$(this).children().toggleClass("hide");
});
}
function fold2(){
$("#container").on("click", "#nav > li > ul > li", function(){
$(this).children().toggleClass("hide");
});
}
fold1();
fold2();
}
Is there a way to fix this? Or a better (cleaner) way to make collapsible nested lists with dynamic content?
Aucun commentaire:
Enregistrer un commentaire