React to AJAX adding to the page

Found this at https://codex.wordpress.org/AJAX_in_Plugins JavaScript triggering the post-load event after content has been inserted via Ajax: jQuery( document.body ).trigger( ‘post-load’ ); JavaScript listening to the post-load event: jQuery( document.body ).on( ‘post-load’, function () { // New content has been added to the page. } ); I suppose it’s up to each plugin to trigger whichever … Read more

The script works only once by clicking on the opening and closing

In general, here is my solution code: <script type=”text/javascript”> // Выполнить асинхронный Ajax-запрос с помощью метода POST. // Отправить данные на сервер и в случае успеха вывести // ответ сервера в диалоговом окне. //jQuery(document).die(‘click’, ‘#order_’+button.id) ; function showPopup (button) { jQuery(document).on(‘click’, ‘#’+button.id, function(event) { jQuery.ajax({ url: ‘/wp-admin/admin-ajax.php’, // сделали запрос type: “POST”, // указали метод … Read more

Execute inline javascript in wordpress after page fully loaded

I think you should in this case use echo: function print_script() { echo ‘<script type=”text/javascript”> window.onload = function () { var loadTime = window.performance.timing.domContentLoadedEventEnd-window.performance.timing.navigationStart; alert(loadTime); console.log(loadTime); } var var1 = <?php echo json_encode(‘var1’); ?>; var var2 = <?php echo json_encode(‘var2’); ?>; var var3 = <?php echo json_encode(‘var3′); ?>; </script>’; } add_action(‘wp_print_scripts’, ‘print_script’);

Multiple image selection custom widget

I’ve found a solution by myself! With two lines of code I’m now able to save all the selected images and then retrive them on the front-end. I have added an array in the JS code part: // media library script (function($){ $(document).ready(function(){ $(document).on(‘click’, ‘.upload_image_button’, function(e){ e.preventDefault(); var button = $(this); var file_frame = wp.media.frames.file_frame … Read more