I'm building a page where users can place multiple containers with input fields that can be edited in place. My script at the moment allows me to edit in place the input fields on click but I'm running into 2 issues:
I need to edit each form individually. At the moment when click on Edit all of the fields in the other containers become editable as well.
When click cancel nothing should be saved if anything was typed.
JQuery
var readonly = true;
$(".edit").on("click", function(e) {
$('input[type="text"]').attr("readonly", !readonly);
readonly = !readonly;
$(".edit").hide();
$(".button-group").show();
});
$(".save, .cancel").on("click", function() {
$(".button-group").hide();
$(".edit").show();
$('input[type="text"]').attr("readonly", !readonly);
readonly = !readonly;
});
Thank you!