Page 2 of 3

How to update Local Storage Array

Posted: Mon Aug 24, 2015 2:29 pm
by Randy7611273

How to update Local Storage Array

Posted: Tue Aug 25, 2015 11:55 am
by Serhii Kulibaba

Could you show us screenshots where you set storage variable?


How to update Local Storage Array

Posted: Tue Aug 25, 2015 2:30 pm
by Randy7611273

How to update Local Storage Array

Posted: Thu Aug 27, 2015 5:00 am
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.


How to update Local Storage Array

Posted: Fri Aug 28, 2015 3:51 am
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";


How to update Local Storage Array

Posted: Sun Aug 30, 2015 4:32 pm
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


How to update Local Storage Array

Posted: Sun Aug 30, 2015 7:30 pm
by Randy7611273

How to update Local Storage Array

Posted: Mon Aug 31, 2015 5:00 am
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.


How to update Local Storage Array

Posted: Mon Aug 31, 2015 3:56 pm
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!


How to update Local Storage Array

Posted: Wed Sep 02, 2015 9:39 am
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