Welcome to our Knowledge Base
Categories
< All Topics
Print

JQuery Events and Functions

Available Custom jQuery events:

wpc-button-completed
wpc-button-completed::post ID-Button Name
wpc-page-completed
wpc-page-completed::post ID
wpc-course-completed
wpc-course-completed::Course Name

Examples:

Want to trigger some javascript once the user completes a page?

jQuery(document).on('wpc-page-completed', function(e) {
// do something awesome!
});

Need something to happen when a specific page is completed? Use the post’s ID:

jQuery(document).on('wpc-page-completed::430', function(e) {
// do something awesome!
});

Want to celebrate when your students finish any of your courses?

jQuery(document).on('wpc-course-completed', function(e) {
// Trigger confetti falling or something else awesome!
});

Only want to celebrate when they finish a specific course?

jQuery(document).on('wpc-course-completed::Course Name', function(e) {
// do something awesome!
});

You can also use this for when buttons are completed. If you want to do it for ANY button, use:

jQuery(document).on('wpc-button-completed', function(e) {
// trigger custom javascript!
});

If you want to trigger when a SPECIFIC button is completed, use that button’s post ID and name:

jQuery(document).on('wpc-button-completed::430-Video-3', function(e) {
// trigger custom javascript!
});

To mark a button as complete with javascript, you’d use:

jQuery(document).ready(function() {
wpcomplete.complete(ID);
});

This is a way to manually re-trigger adding the wpc-lesson and wpc-lesson-completed classes for any links that have been added to your site since page load or last button completion. This is helpful when you’ve loaded content via an AJAX call, which has added new links to your page:

wpcomplete.linkify();

Table of Contents