I was wondering how I would be able to hide a post with jquery. I was able to get the posts to hide using this code from the jquery api
<head>
<style>
span { background:#def3ca; padding:3px; float:left; }
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<button id="hidr">Hide</button>
<button id="showr">Show</button>
<div>
<span>Once</span> <span>upon</span> <span>a</span>
<span>time</span> <span>there</span> <span>were</span>
<span>three</span> <span>programmers...</span>
</div>
<script>
$("#hidr").click(function () {
$("span:last-child").hide("fast", function () {
// use callee so don't have to name the function
$(this).prev().hide("fast", arguments.callee);
});
});
$("#showr").click(function () {
$("span").show(2000);
});
</script>
</body>
but the problem is that this doesn’t save the hide so when I refresh the browser the post is shown again. I want to be able to have the user who posted the post press hide and have the post hide for him but also hide for everyone else on the site. I’m not sure how to make this work though so I could use some help.
If you want the behaviour
> but also hide for everyone else on the site
you will have to persist the state of the sections in a database. Then you can build a helper that returns you if a section has to be displayed or not based on the section’s id…