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 6017011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:04:03+00:00 2026-05-23T03:04:03+00:00

What is the best way to handle an observable array which can be committed/thrown

  • 0

What is the best way to handle an observable array which can be committed/thrown away in KnockoutJS?

I’ve achieved this before with the ProtectedObservable idea but this was on a single record of data, not on an array.

Just wondered how to best go forward. My project requires a dialog of all email address contacts and a list of those selected. As they are added from a list on the left, they are removed and get added to a list on the right.

When the ‘ok’ button is pressed, they are added into the To: field but when ‘cancel’ is pressed the lists are restored to their previous state (which could already have been populated before).

  • 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-23T03:04:04+00:00Added an answer on May 23, 2026 at 3:04 am

    How about something like this: http://jsfiddle.net/rniemeyer/PAzVk/

    This uses an observableArray that supports “snapShots”. You can save a copy of the underlying array and restore it whenever you need to.

    ko.snapShotObservableArray = function(initialData) {
        var _snapShot = initialData;
        var result = ko.observableArray(initialData || []);
    
        result.takeSnapShot = function() {
            _snapShot = this().slice();  //take a copy of the underlying array
        };
    
        result.restoreSnapShot = function() {
           this(_snapShot.slice());   
        }
    
        return result;
    }
    

    In the sample, you would use this on you array of available users, array of selected users, and array of users on the “To” line. Then, the cancel button restore each array back to the point that you took the last snapshot.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to find the best way to handle creating an ISO 8601
Is <area> still the best way to handle irregular navigation menus, or is there
There doesn't seem to be any tried and true set of best practices to
I am building an android game which is intended to be a multiplayer game.
I need to develop a file indexing application in python and wanted to know
I've found several jQuery syntaxes for nullifying the enter on a form. First one:
I'm new to Rails development and I have a question about handling an unknown
I have a user with a profile picture. The picture will be converted into
I have a variable keypress that gets set when a phone call is made
Scenario: Retrieve some entities Update some properties on those entities You perform some sort

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.