JavaScript Events
Estimated reading: 1 minute
2423 views
Overview
WP Reactions Pro provides JavaScript events that you can listen to them to do certain actions after user react, share and etc.
Events
user.react – occur after user react to one of emojis. Function will get reacted emoji jQuery object as second parameter.
Following example sends Ajax request after user reaction.
$('.wpra-plugin-container').on('user.react', function(e, $reacted_to) { if ($reacted_to.data('emoji_id') === 3) { send_some_ajax(); } });
user.share – occur after user try to share on a platform. Function will get social platform name as second and platform data as third parameter.
Following example sends Ajax request when user is trying to share on facebook.
$('.wpra-plugin-container').on('user.share', function(e, platform, data) { if (platform === 'faceboook') {
send_some_ajax(); } });