I am creating a web application to hold items in a list. Prior to re-engineering my front-end to be run on a server and having the contents stored and maintained in-memory on the server, I was using buttons to edit and delete items. These buttons then had event listeners that upon being clicked, javascript functions did their thing.
I am now developing it into a RESTful spa and have no idea how to call the PUT and delete methods. I read that forms/buttons don't support PUT and DELETE, and using POST is bad practice since it's not idempotent.
How do I go about this? Do I need to use some sort of plug-in to be able to achieve this? Is it possible to achieve this without javascript functions?
This how an item is structured in a list in my html:
<li class="list-group-item">
<span class="description"><%= item %></span>
<button class="btn btn-default btn-xs pull-right" id="delete-button" formaction="/items/<%= item %>" formmethod="delete" type="submit">
<i class="glyphicon glyphicon-trash"></i>
</button>
<button class="btn btn-default btn-xs pull-right" id="update-button" formaction="/items/<%= item %>" formmethod="put" type="submit">
<i class="glyphicon glyphicon-pencil"></i>
</button>
</li>
I know the formmethod
tags are incorrect there - left them to explain what I'm trying to achieve