Mootools Array Part1

MooTools={version:1.3,build:a3eed692dd85050d80168ec2c708efe901bb7db3}

Mootools 1.3 add array, update array, delet array

var dataArray = [ {unid:'a', first:Rob, last:Jones}, {unid:'b', first:Tim, last:Reime}, {unid:'c', first:Josh, last:Smith}];

function addNewData(sUnid,sFirst,sLast){ var dataArray_new =[{unid:sUnid,first:sFirst,last:sLast}]; dataArray.append(dataArray_new);}

function updateData(sUnid,sFirst,sLast){ dataArray.each(function(item){ if(item.unid == sUnid){ item.first = sFirst; item.last = sLast; } });}

function deleteData(sUnid){ dataArray.each(function(item){ if(item.unid == sUnid){ dataArray.erase(item); } });}//------------------console.info(dataArray);

addNewData('d',Tom,Jones);
console.info(dataArray);

updateData('d', Will, Dante);
console.info(dataArray);

deleteData('b');
console.info(dataArray);

dataArray.empty();
console.info(dataArray);

http://jsfiddle.net/Naprej/6VyaV/