Saqib Abbas

Saqib Abbas

  • 1.9k
  • 6
  • 1.6k

Return only changed fields.

Jan 27 2015 5:23 AM
Hi there!

I am dynamically creating views using JQuery which consists of a tables that has editable fields i.e every td contains an input of type text. As soon as the user makes changes to any field I want the entire row corresponding to the field to be pushed into an array and then that array be passed to a http-post  action method where the changes can be made to data base using ado.net. This is what i tried which does not work as the array passed on the action method is always empty can anyone tell me what is wrong with it? Thanks in advance.
   
 //This function gets invoked on button click     
 function getAllChanges() {
   
 //Declared earlier
 arr1 = new Array();
 $.each("#tblSubDepts tbody tr input[type='text']".change(function () {
 
//push parent, that is the 'tr' into arr1
 arr1.push(this.parent);
 }));
 return arr1;
 }

 
 P.S
data attribute of ajax call that i am using
data: JSON.stringify({obj:(getAllChanges())}) 
 

















Answers (2)