Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6612479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:06:12+00:00 2026-05-25T20:06:12+00:00

So I’ve been working with 2 different Localstorage application for a task I’ve been

  • 0

So I’ve been working with 2 different Localstorage application for a task I’ve been given. The one is a todo list and the other one is notes which both work on the same html file.

Now, the todo list have 3 localstrorage keys. One for the value of the todo. Second for the order of the todo’s (which is first, sec, third etc) and Third how many todo’s you have in general. So thats 3 different values.

For the notes is 1 localstorage Key with all its values. (see image below)

Now the problem is: If for example I have 3 notes and then I add a todo I get this on the localstorage:

enter image description here

which this is working fine.

But, if I add another two notes, I get this:

enter image description here

which is logical although the last two notes doesn’t show.

Another example:
enter image description here

This will not show any notes although there are 4.

I’m not sure how to explain this but basically what happens is that what ever is written on the localstorage after a todo-ID, doesn’t show but note that the todoList keeps working perfectly.

I’m not pretty sure what the problem is but what I think it could be its the way the keys are being loaded. maybe ???

So here is how I load the notes:

var initStickies = function initStickies() {
    $("<div />", { 
        text : "+", 
        "class" : "add-sticky",
        click : function () { createSticky(); }
    }).prependTo(document.body);
    initStickies = null;
},
openStickies = function openStickies() {
    initStickies && initStickies();
    for (var i = 0; i < localStorage.length; i++) {
        createSticky(JSON.parse(localStorage.getItem(localStorage.key(i))));
    }
}

and this is how I load the todo-list:

orderList = localStorage.getItem('todo-orders');

orderList = orderList ? orderList.split(',') : [];

for( j = 0, k = orderList.length; j < k; j++) {
    $itemList.append(
        "<li id='" + orderList[j] + "'>"
        + "<span class='editable'>" 
        + localStorage.getItem(orderList[j]) 
        + "</span> <a href='#'>X</a></li>"
    );
}

What the problem could be? Does anyone had this problem before?

Thanks alot for reading and sorry for the big post. I’m trying to be as clear as possible. I’ve been thinking how to fix this for really long time and im coming to a dead line. Hope someone can help me. Thanks again

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:06:12+00:00Added an answer on May 25, 2026 at 8:06 pm

    In your notes app, you try to iterate through every item in localStorage and parse them as JSON. When it gets a JSON string, it successfully parses it and continues its work. When it gets your todo item, it breaks and stops working. If you want to have both todo and note in one localStorage, you’d better have some way to tell the difference. One simple way is to have todo- as prefix for todo item (as you’ve alreayd done) and note- as prefix for note item.

    One possible quick fix for your code is to use try ... catch ... to avoid non-JSON string breaking your iteration:

    for (var i = 0; i < localStorage.length; i++) {
        try {
            createSticky(JSON.parse(localStorage.getItem(localStorage.key(i))));
        } catch (error) { /* do nothing and just skip */ }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
I have a text area in my form which accepts all possible characters from
I am writing an app with both english and french support. The app requests
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.