Load All Articles on Category Page

I added a little function for myself – not necessarily everyone will love it. My last discussion about Full Content on Home Page of my Blog actually turned out to a conclusion that my readers love its current design (or to better put it, hate change). So I will try not to change stuff too much.

On the category page, I used to have a list of all the articles in the category, with a link to the original article, and excerpt. It is nice for people to read that article, and the comments(!).

From time to time, I want to review all the articles without going into each link – I never succeeded in clicking every link on the page to read every article.

So… I think of workaround – a way to add that function without change the old layout.

The New Button

Now, visit any of the category page, like this one, you will see a big button “Load all articles”. Clicking the articles, you will see all the articles loaded on the same page for you to quickly review. Reload the page restore it to the original view.

The Code

In case you want to know how I did it, just the following simple codes:

<input type="button" value="Load all articles" id="preview">

....

<script src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>

<script>

$("#preview").click(function(){

$("li a").each(function(){

$(this).parent().load(this.href + " h1, div > div> p");

});

});

</script>

It is a very simple JQuery code. It basically tells the browsers when a button named “preview” is called, for each a tag under li tag, load the HTML specified by the href attribute into the parent node. Then only gets the p tag under two div tag…

Anyway, skip this part if you are not technical type of person.

Your Comments

What would you like? The expanded view (with the contents) or the original view?

2 thoughts on “Load All Articles on Category Page

  1. I like the original view with the opportunity to expand them all if necessary, or to go directly to the one I might be looking for. If searching for something specific, it’s easier to scan down a brief list with the essential information about each post than it would be to scroll through the entire text of every post before coming to the one in which you are interested.

    That said, I don’t remember seeing *any* of those original posts about bookstores. They were very interesting, especially the amazing drawing lesson you provided about parallel lines!!

    I may not be a “geek” (definitely not!) but I am endlessly fascinated by the things I can learn from reading some of your more technical posts, Jian Shuo. Thanks for expanding my world :-)

Leave a Reply

Your email address will not be published. Required fields are marked *