Question

Photo of Ben Goshow

0

Reload scripts after Rock AJAX runs?

Using the CalendarLava.ascx Block out of the box, the mini-calendar month-to-month navigation uses some form of AJAX to reload the event list (also if you select a specific day or date range. You can see the little Rock loading animation between views)

We have some javascript working on the original list of events, but it stops working after any AJAX is run, I assume because the new list of events wasn’t in the original DOM. If I bundle our script into a function, is there anyway to call that function after the Rock AJAX runs each time?

  • Photo of Jon Edmiston

    1

    You might  try binding your events like


    script>
        Sys.Application.add_load( function () {
           ...
        });
    </script>
    Instead of
    <script>
        $( document ).ready(function() {
             ...
        });
    </script>
  • Photo of Ben Goshow

    0

    At first I tried that in an external scripts.js file and it didn’t recognize `Sys` but loading it into the post HTML block works perfectly. Thanks!