I'm writing a software which has views such as calendar and customer search. For example the main page contains links to these subsections. When the user navigates to the calendar page, the events of today are loaded from the backend via AJAX query. When an individual event is opened from the calendar view, its details are again loaded from the backend dynamically.
The first prototype was written as one big HTML file with all the JavaScript code embedded directly. Now I've started to refactor this into a more manageable system.
The problem is that I would like to separate each view as its own page which could be used independently but also as part of jQuery Mobile site with smooth AJAX transitions. Based on my observations loading a page via AJAX link in jQuery Mobile means that from the target page only the element marked with data-role="page" attribute is injected into the source page's HTML. All the script tags are stripped.
How should I separate the views but still maintain the smooth AJAX transitions?