How to update Local Storage Array

This forum contains topics that were moved from Get Satisfaction
Randy7611273
Posts: 0
Joined: Sat Jun 27, 2015 7:03 pm

How to update Local Storage Array

Post by Randy7611273 »

Serhii Kulibaba
Posts: 147
Joined: Tue Aug 27, 2013 1:47 pm

How to update Local Storage Array

Post by Serhii Kulibaba »

Could you show us screenshots where you set storage variable?

Randy7611273
Posts: 0
Joined: Sat Jun 27, 2015 7:03 pm

How to update Local Storage Array

Post by Randy7611273 »

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

How to update Local Storage Array

Post by Yurii Orishchuk »

Hi Randy,

as i can see you have storage with name "votedReturn".

In your case you have:
storage "liveEventArray" with type - array of "liveEvent" model(where you have "votedReturn" parameter )

So your code will not work(cause of you use "votedReturn" as storage name):

pre

Apperyio.storage.votedReturn.update("$['thisVote']", true);

/pre

You need to access "Apperyio.storage.liveEventArray" storage instead.

Also it's not clear what you want to update in this storage. It's better to update with following way:

pre

var liveEventArray = Apperyio.storage.liveEventArray.get();

//here you can alter your array in way you need. Like:
liveEventArray[0].votedReturn = "true";

Apperyio.storage.liveEventArray.set(liveEventArray);

/pre

Regards.

Randy7611273
Posts: 0
Joined: Sat Jun 27, 2015 7:03 pm

How to update Local Storage Array

Post by Randy7611273 »

Hi Yurii,

Thank you for your patience with me... I think we're almost there! With the above code, I am able to change the value of votedReturn at array index 0 [0]. How can I either
(1) get the index value and set it based on a variable

  • or -
    (2) change votedReturn where songID = clickedSong?

    liveEventArray[ where songID = clickedSong <<< ].votedReturn = "true";

Randy7611273
Posts: 0
Joined: Sat Jun 27, 2015 7:03 pm

How to update Local Storage Array

Post by Randy7611273 »

We're so close! How can I get the index value from the Local Array for the 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);

I need to get the Local Array index value for this item, but have not yet been able to do so.

Image

Below code (currecord) returns the number of records, not the index of the clicked item:
Image

Randy7611273
Posts: 0
Joined: Sat Jun 27, 2015 7:03 pm

How to update Local Storage Array

Post by Randy7611273 »

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

How to update Local Storage Array

Post by Yurii Orishchuk »

Hi Randy,

That's what i see in your code, take a look on following screen shot:

http://prntscr.com/8arlyy/direct

Regards.

Randy7611273
Posts: 0
Joined: Sat Jun 27, 2015 7:03 pm

How to update Local Storage Array

Post by Randy7611273 »

How can I get the index for a_id? The below code properly filters and returns the clicked object... I just need the index.

return item.a_id === searched;

Please help!

Serhii Kulibaba
Posts: 147
Joined: Tue Aug 27, 2013 1:47 pm

How to update Local Storage Array

Post by Serhii Kulibaba »

Randy,

You have you use JS like this:

prefor (var i = 0; i < currecord&#46;length; i++){
if ( currecord&#46;a_id === searched ){
alert("searched!");
}
}/pre

Post Reply