Views provides custom events you can use to trigger your custom JavaScript code. This allows your custom JavaScript code to work even after Custom Search or Pagination results are updated using AJAX.

If you add code to an element using the document.ready jQuery method this code will stop working when a View is updated via AJAX through custom searches or pagination. This is why you need to reattach it to your page.

To preserve your JavaScript code from getting lost you have to do the following:

  1. Expand the JS editor (below the main Search and Pagination editor).
  2. Click the Frontend events button as shown in the following image.

Expand JavaScript editor
Expand JavaScript editor

  1. The Insert Views frontend event handler dialog appears. You can select events that belong to one of the following features:
    • Pagination
    • Custom search
    • Google Maps (available only when Toolset Maps plugin is active)

    Select events you want to insert the code for and click the Insert event trigger button.

That’s it! Now, you can add your custom JavaScript callbacks to the code that Views inserted into the JS editor.