Skip to content

Instantly share code, notes, and snippets.

@codenamejason
Created December 6, 2017 15:29
Show Gist options
  • Save codenamejason/15cdb8c0014e8718448e422c4d5f436f to your computer and use it in GitHub Desktop.
Save codenamejason/15cdb8c0014e8718448e422c4d5f436f to your computer and use it in GitHub Desktop.
Get Matching Item From Selectables
function GetMatchingItemFromSelectables(item, selectablesList) {
var chosenIndex = -1;
if (item !== undefined && item !== null) {
if (item.Key !== undefined) {//this section is deprecated, old way of doing selectables
for (var t = 0; t < selectablesList.length; t++) {
if (selectablesList[t].Key === item.Key) {
return selectablesList[t];
}
}
}//--end of deprecated section
else {
if (!item.id) {
return item;
}
for (var t = 0; t < selectablesList().length; t++) {
if (selectablesList()[t].id() === item.id()) {
return selectablesList()[t];
}
}
return item;
}
}
return { "Key": "", "Value": -1 };
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment