Showing all results on success - then hide X amount
I have this开发者_StackOverflow社区 page:http://www.ryancoughlin.com/files/xml/ - if you select User -> Someones name
You will see a table populate. I am trying to only show JUST the results of the user you selected. Since I am actually loading an XML file I cant really send data to it. So I figured, load them all then hide EVERY entry but the one you selected from the dropdown.
Any ideas?
Here is an example of the code I am using to hide: line 145
single_user.find(name_select+":not()").each(function(){$(this).hide();});
The variable name_select
is the value of the OPTION tag from the dropdown on the previous screen.
You should reverse your thinking - hide the rows by default, then show the one you want.
As you append each table row, add the Name value as the id, and add a class to the <tr>
element that has a display:none
style. This will prevent all the rows from flashing as they are loaded then hidden.
After the load process completes, show the row where the name_select value matches the id attribute.... $("#" + name_select).show();
Simple example:
<html>
<head>
<script language="javascript" src="../code/jquery-latest.min.js"></script>
<style>
tr {
display:none;
}
</style>
<script language="javascript">
$(document).ready(function() {
$("#3").show();
});
</script>
</head>
<body>
<table>
<tr id="1"><td>1</td></tr>
<tr id="2"><td>2</td></tr>
<tr id="3"><td>3</td></tr>
<tr id="4"><td>4</td></tr>
</table>
</body>
精彩评论