Injecting JavaScript into HTML
Once we have finished this section, we will have a not so pretty but fully functional main view where we can add, edit, and delete to do items using JavaScript to make calls to our Rust server. However, as you may recall, we did not add a delete API endpoint. In order to inject JavaScript into our HTML, we will have to carry out the following steps:
- Create a
deleteitem API endpoint. - Add a
JavaScript loadingfunction and replace the JavaScript tag in the HTML data with the loaded JavaScript data in the main item Rust view. - Add a JavaScript tag in the HTML file and add IDs to the HTML components so that we can reference the components in our JavaScript.
- Build a
renderingfunction for our to-do items in JavaScript and bind it to our HTML via IDs. - Build a
button renderingfunction in JavaScript based off item data for the ID. - Build an
API callfunction in JavaScript to talk to the backend. - Build the
get,delete,edit, and...