Open edwardsmarkf opened 6 years ago
var list=[
{value:"test 1"},
{value:"test 2"},
{value:"test 3"}
]
watch(list,function(name,type,val,oldval){
// get index
var index = list.indexOf(this);
console.log(index,name,type,val,oldval);
});
list[1].value="new value";
// 1 'value' 'set' 'new value' 'test 2'
I need to be able to do this too. Writing var index = list.indexOf(this);
always returns a value of -1
for index and { get: [Function] }
for this
. Am I missing something? Can can I tell the index of the object that was changed in when watching an array of objects?
hello -
if i were using an array of objects like this:
is it possible to get the row number? this works great:
obj[0].firstName='MARK'; // triggers alert with property, oldvalue and newvalue
Is there any way to determine the changed row number, or perhaps the id value?also, is there any way to watch for inserts and deletes?
thank you very much.