Hi, I have a Javascript object that basically represents a Row in an .NET GridView. When a user clicks on any row in the grid, all the input elements in that row are 'enabled'.(ie 'Edit' mode).
I run this code depending on which row is selected
$(":input", this._row).attr('disabled', true);
or
$(":input", this._row).removeAttr('disabled');
So far so good. Now, I want to keep track of the values in that row before a user enters the 'Edit Mode', so i can restore the original values if they decide to click out of that row without saving any changes that they made.
So i capture the original values in an array by doing this:
var $inputs = $(":input", this._row);
var values = {};
$inputs.each(function(i, el) { values[el.name] = $(el).val(); });
the 'values' array now looks like this:
ctl00$ContentPlaceHolder1$resultsGrid$ctl04$COMPONENT1 "56"
ctl00$ContentPlaceHolder1$resultsGrid$ctl04$COMPONENT2 "98"
ctl00$ContentPlaceHolder1$resultsGrid$ctl04$COMPONENT3 "08"
ctl00$ContentPlaceHolder1$resultsGrid$ctl04$COMPONENT4 "200"
Great so far. The user may then modify these values, but decide not to save the changes. So i need to restore this row back to it's orignal values from the 'values' array. Can someone tell me the best way to do this? Im hoping it's something simple, but i'm no jquery expert, yet..
thanks