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 ...

Get Hands-On Full-Stack Development with Swift now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.