From the course: Building Full-Stack Applications with HTMX
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Solution #4: Adding a new article - HTMX Tutorial
From the course: Building Full-Stack Applications with HTMX
Solution #4: Adding a new article
- [Instructor] So it's time to add new articles to our blog project. The first set of instructions are all for creating our form template that will be displayed to the user. We had to create a form template that takes in an error and values argument, which will be used in error scenarios to display errors and submitted values. The form should also contain two fields, for the article title and content. The required attribute should be placed on the fields, and the form is to be submitted to the /articles POST endpoint. You already have the GET version of that endpoint. Now we're going to create the POST version. The response should then be loaded into the main page content view. So let us write all that. Going to create a new template in the template folder that will be called articleForm.js. And I'm just simply going to write all the code required for all the descriptions that we just heard. So here we are exporting the template. It takes in the error and the values arguments as…