I'm using a session storage to temporarily hold data and try to search for a string (CatalogNumber
) in the session data. If the string isn't existing I'd like to add it.
This is what I've tried so far but it's still allowing duplicates. And the search isn't working for the array for some reason:
var gridData = {
catalogNumber: dataItem.CatalogNumber,
fullName: dataItem.FullName,
position: dataItem.CurrentTitle
};
sessionStorageData = JSON.parse(sessionStorage.getItem('people'));
if (jQuery.inArray(gridData.catalogNumber, sessionStorageData ) === -1) {
sessionStorageData.push(gridData);
sessionStorage.setItem('people', JSON.stringify(sessionStorageData));
}
Data
[{"catalogNumber":"51263bf7-83c4-e411-825d-28b2bd14ba94","fullName":"John Doe","position":"Receptionist"}]