I have a ul having li's. Each li has a div having the actual text. I am programmatically adding the li's depending on the contents of a json object I have loaded using ajax with async false. Depending o开发者_Go百科n the json each ul has a different id. In the function where I am creating the ul I am adding it to the document and then retrieving it for making the treeview call. I am simply using the treeview call and dont need any other options.
$(str1).html('<div id = hiddenDivforList>'+list+'</div>');
$("#"+strId + "~labelList").treeview();
The id is fine I have checked in the html using firebug. But there is no change in the display of the list after the treeview call!
Kindly help me with this Kavita
Sorry Here is the sample i am running
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="Styles/jquery.treeview.css" />
<script type="text/javascript" src="Scripts/jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="Scripts/jquery.tools.min.js"></script>
<script type="text/javascript" src="Scripts/jquery-layout.js"></script>
<script type="text/javascript" src="Scripts/jquery-ui.js"></script>
<script src="Jquery/jquery.cookie.js" type="text/javascript"></script>
<script src="Jquery/jquery.treeview.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$("#name1").treeview({
animated: "fast",
collapsed: true
});
});
</script>
</head>
<body>
<ul id="name1">
<li><div>data1</div></li>
<li><div>data1</div></li>
<li><div>data1</div></li>
<li><div>data1</div></li>
<li><div>data1</div></li>
</ul>
</body>
</html>
I am not seeing any visible change in the display. No + mark for collapse Kavita
Since you are adding the content dynamically , try to call the treeview on .live().
http://api.jquery.com/live/
精彩评论