Using jQuery’s jscroll Plugin

Recently I was looking around for a quick way to implement infinite scrolling and found the jscroll plugin for jquery.

The problem was that all the examples online were broken and they all seemed to copy and paste from each other which made it difficult to figure out what worked. Finally I got something working and just wanted to post the options that I was using for anyone else that needs help with it.

The HTML


<h1>Welcome To the Site</h1>
<div class="infinite-scroll">
This is a sentence
<a class="next-link" href="/path/to/next/page">Link to next page response</a>
</div>

The JavaScript


console.log('Starting the scrolling script');
$('.infinite-scroll').jscroll({
debug: false, // Show debugging info in console
autoTrigger: true, // Start fetching without clicking a "next" link
autoTriggerUntil: false, // How many pages to auto trigger until requiring "next" click
loadingHtml: '<img src="/images/loading.gif" alt="Loading" />', // What to show when loading responses
padding: 20,
nextSelector: 'a.next-link:last', // The link with an href to the next response to load
callback: function () {
// Function called when the response is loaded
console.log('callback was called');
}
});

Backend API

Depending on your framework, create an endpoint that returns a response containing your content and a link to the next item to load (a link element) at the end. It is important that this response contains the HTML necessary for the item you are rendering and is not just a JSON response.

Freelance Photographer

This was from a conversation between two classmates years ago when I was in high school. Thinking about it today still makes me laugh and I wonder if either of them might one day stumble upon this and remember, too. (Names changed for privacy.)


 

Alan: What does you mom do?

Judy: My mom is a freelance photographer.

Alan: What does that mean? Free of job?

Judy: No! It means she works whenever she wants to.

Alan: . . . Yeah. Free of job.

My Top 5 Mistakes in Ubuntu

Ubuntu Logo

While I love using Ubuntu, I’ve made my share of (sometimes disastrous) mistakes while using it and wanted to share them so no one else falls down the same dark paths that I have walked.

5. Not using the Long Term Support (LTS) Versions

Each version of Ubuntu just keeps getting better and better, but sometimes upgrading to the latest version isn’t the best choice. If you don’t have a lot of patience (or a slow internet connection) this could be problematic as an upgrade could take several contiguous hours, which not everyone can spare. Then of course there are the problems upgrading from one version to another, such as certain programs not working correctly or packages being corrupted, etc. Avoid it all by just sticking to the LTS versions. You’re not missing anything important by playing it safe; rather, you’re saving yourself hours of headache because you’ll only need to update every 5 years instead of every 6 months.

4. Using the command line for something that could have been done through the GUI easily

Learning how to use the command line is important, but if you know your stuff already it’s better to just take the GUI route when you can. Why? The GUI is usually robust enough to avoid making the mistakes you’d make if you were allowed free access to the guts of your Linux distro. The Software Center already knows everything that is has to do, so there is no guess work and no need to cross your fingers. A single mis-typed character on the command line could send your entire computer into utter chaos and you’d never know why.

Continue reading