Hi!
I am a total newb, I did a Django course and I am currently building a project on my own to practice what I’ve learned. Right now I am working on a contacts page for a scheduling app where the user can view/ input and edit their contacts. I am loading all of the data into a data table when I first load the page. I am doing all the CRUD within the page with js and ajax. I am curious as to some advice on how to manage updating an existing entry. Specifically I am interested in some thoughts on the best way / ‘correct’ way to fill out a form with the existing contact info for the user to edit.
Currently, when the user clicks on the edit button for an entry I have written a script that brings up a modal with a form and it fills out the form with the existing values for the user to edit. Right now, since I am already loading all the information when the page loads, i am using the templating language to give my script all of the info to fill out this form like so:
onclick=‘EnsembleModalEdit("{{person.first_name}}","{{person.last_name}}","{{person.email}}","{{person.cell_phone}}","{{person.home_phone}}","{{person.assigned_department.id}}")’
This works fine but I am wondering if there is a better way of doing this. Not 100% sure what best practices are for doing something like this. Should I be retrieving the info I need with ajax every-time I want to edit a contact’s info? Or I could create a different modal for each contact when I first load the page? Any ideas?