A Single-Page Application is a web application that lives within a single HTML page. The "views" of the application are injected into and removed from the DOM as needed as the user navigates through the app. A single-page application architecture is particularly well suited for mobile apps:
In this module, we set up the basic infrastructure to turn Conference App into a single-page application.
In index.html: remove the HTML markup inside the body tag (with the exception of the script tags).
Inside the immediate function in app.js, define a function named renderHomeView() (right after the findByName function). Implement the function to programmatically add the Home View markup to the body element.
function renderHomeView() {
var html =
"<h1>Conference App</h1>" +
"<input class='search-key' type='search' placeholder='Enter name'/>" +
"<ul class='session-list'></ul>";
$('body').html(html);
$('.search-key').on('keyup', findByName);
}
Modify the data service initialization logic: when the service has been successfully initialized, call the renderHomeView() function to programmatically display the Home View.
var service = new ConferenceService();
service.initialize().done(function () {
renderHomeView();
});
Since you moved the registration of the keyup event inside the renderHomeView() function, make sure you remove the original keyup event registration in the Event Registration section.
Since the Help button is no longer there, remove the click event handler for the help button (in the Event Registration section).
Test the application.
Make sure you didn't overlook steps 4 and 5 above, otherwise you may run into hard-to-track issues related to events firing twice later in this tutorial.