Draggable Modal script

I am using a very simple jquery script to allow modals to be moved around the screen. This allows the user to see any information hidden by the modal, useful when there is a form on the modal that needs to be completed and the user needs to refer to information below. This script is written once on the template or parent page of the SPA. The class modal_drag is used on every modal that I want to make draggable.

  <script>
    $( function() {
      $(".modal_drag").draggable();
    } ) ;
  </script>

I am using SPA with two or three modals per SPA page. These are used for New, Edit, Delete etc.

This function works well, but only on the one page. My problem is that when I change (SPA) pages, the script doesn’t work on another SPA page unless I press F5 to refresh the page, then the script works. But if I then change back to the original SPA page, again the script doesn’t work unless I refresh the page. Can anybody help to resolve this issue?

Community Page
Last updated: