What my code does:
- An "Add Item" button brings up a popup (#addquoteitem) that contains a form
- submission of that form 1. creates a new row in a table, from a template and 2. creates hidden inputs (not hidden in jsfiddle) because I thought this was easiest way to submit the data to server
- A "submit quote" button then submits each of these rows individually to the server via the "hidden input" form
I did not realize until I was done ( I am working on my first big project ), The user can not edit their individual items!!!
What I think I should do:
- Add an edit button for each row that brings up a popup, which would use jquery to change the values of the corresponding rows
- Then change it so the "hidden inputs" are not created until the final "submit quote" button is pressed.
JSFIDDLE http://jsfiddle.net/SteveRobertson/XHuVS/1/ JSFIDDLE
My Question: Is my approach the correct method? I only ask because I do not think it is, but feel as though I have coded myself into a corner. I have no idea what to do. if not. What is the correct method for dynamically editing rows in a manner they can be submitted to a server? When I call this function for the template, I assume I have to add a counter of some sort to give each row a unique ID, or can the row be identified in another manner?
function template(row, quoteItem) {
row.find('.item_num').text(quoteItem.number);
row.find('.item_desc').text(quoteItem.description);
row.find('.item_price').text(quoteItem.price);
return row;
}
Although I do no know how exactly to do most of the methods my approach entails I only ask for a point in the right direction. I understand this is a lengthy question as well as lengthy code. I appreciate you taking the time to read this and any suggestions or advice. Thank You.