Adding JavaScript
Our Vapor server now looks great and renders a beautiful web page, but, at the present, is not very functional. It has an add link and a cross button to delete a Shopping List and an item, but none of these work. The reason is because we have not written code to do anything when a user clicks on the link or on the delete button. To add this functionality, we will need to write some JavaScript. We have created an app.js
file, but it is currently empty. So let's see how we can add the same functionality as our native iOS app to add, edit, and delete a Shopping List and its items. We will use jQuery, which is a popular JavaScript library that we have included in our base.leaf
template to help us achieve dynamic behavior in our web app. In the following section, we will look at the code snippets that we need to add to our app.js
file to add a similar functionality as our iOS app to our web app.
Creating a new Shopping List
To add the functionality to create a Shopping List on...