JavaScript Triggers

JavaScript triggers can come in handy when you need something to happen a certain way or at a certain time. Below are the triggers available.

You will need some basic JavaScript knowledge to use them.

I also have a code snippets library and a JavaScript boilerplate to get you started. Have fun.

When viewing another post.

This is triggered when the viewer is reading another post.

jQuery('body').trigger( 'alnp-post-changed', [ this_title, this_url, this_post_id, post_count, stop_reading ] );

An example of using this trigger would be to track analytics of your choosing if not Google Analytics.

Override Post URL

This is triggered before the post is fetched. This is useful should you wish to change the url of the next post to load after X amount of posts.

jQuery('body').trigger( 'alnp-post-url', [ post_count, post_url ] );

Manipulate Post Data

Can be used to manipulate the post data. This is triggered before the post is appended.

jQuery('body').trigger( 'alnp-post-data', [ post ] );

After a post has loaded.

Can be used to do anything once a post has loaded.

jQuery('body').trigger( 'alnp-post-loaded', [ post_title.text(), post_url, post_ID, post_count ] );

An example of using this trigger would be to limit the amount of posts per session and prevent further posts from loading once the post_count has reached it’s total.