Should Javascript EVER be required with Vapor/Leaf, e.g. to add to an HTML element?

I'm new to Vapor -and- to building websites.

I have a small table of numbers (5 by 5) displayed. Each number is paired to one other number in the table.

I want the user to be able to tap on any of the numbers, and have that number -and the corresponding paired number- to be highlighted by adding, say, a property to the HTML elements for those two numbers.

With Javascript this would be done using "element.appendChild(extraProperty)". Is it reasonable to include some Javascript with my Vapor app, or is there a way of doing this via Vapor/Leaf? This is more than just showing one of two elements depending on the value of a variable.

All suggestions appreciated, thanks.

(As answered in Discord)

Yes absolutely - Leaf is server side rendering and JS is all client side. So using JS after Leaf has returned the response to the client is perfectly valid.

Terms of Service

Privacy Policy

Cookie Policy