How to get Index of Local Array Object
How can I get the index value from the Local Array for a clicked item? The working code below is JS on the button in the displayed list:
//-----
//This Vote
var row = jQuery(this).closest("tr");
var thisSong = row.find('[name="id"]');
var thisSongID = thisSong.text();
//console.log("clickedSong", thisSongID);
localStorage.setItem('id', thisSongID);
//-----
The (mostly) working code below returns the array count instead of the index value I need:
//-----
Appery.localService2JS = Appery.createClass(null, {
init : function(requestOptions) {
this.requestOptions = $.extend({}, requestOptions);
},
process : function(settings) {
if (this.requestOptions.echo) {
settings.success(this.__requestOptions.echo);
} else {
var cdata = JSON.parse(localStorage.getItem("liveEventArray"));
var thisVote = (localStorage.getItem("_id"));
var searched = thisVote;
var liveEventArray = Apperyio.storage.liveEventArray.get();
Code: Select all
var index = [0];
var x = 1;
console.log(liveEventArray);
// below works at variable!
liveEventArray[x].votedReturn = "true";
Apperyio.storage.liveEventArray.update(liveEventArray);
var match = cdata.filter(function(item) {
var currecord = thisVote[index];
console.log(currecord, "currecord");
return item.a_id === searched;
});
settings.success(match);
settings.complete('success');
}
} });
//-----
Thanks so much for your help!
Randy