Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Hands-On Full-Stack Development with Swift

You're reading from   Hands-On Full-Stack Development with Swift Develop full-stack web and native mobile applications using Swift and Vapor

Arrow left icon
Product type Paperback
Published in Mar 2018
Publisher Packt
ISBN-13 9781788625241
Length 356 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Ankur Patel Ankur Patel
Author Profile Icon Ankur Patel
Ankur Patel
Arrow right icon
View More author details
Toc

Table of Contents (19) Chapters Close

Title Page
Copyright and Credits
Dedication
Packt Upsell
Contributors
Preface
1. Getting Started with Server Swift FREE CHAPTER 2. Creating the Native App 3. Getting Started with Vapor 4. Configuring Providers, Fluent, and Databases 5. Building a REST API using Vapor 6. Consuming API in App 7. Creating Web Views and Middleware 8. Testing and CI 9. Deploying the App 10. Adding Authentication 11. Building a tvOS App 1. Other Books You May Enjoy Index

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

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime
Visually different images