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

  • SEARCH
  • Home
  • 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

Can someone explain the best way to handle this approach. I am using TinyMCE
Is this the best way to handle file moving in a windows service? we
What is the 'best' way to handle the html markup for partial views? (which
Which is the best way to handle a system error in ASP.NET MVC? I've
Which is the best way to handle creating an object to live in a
What is the best way to handle this? Say I have a listing of
I'm looking for the best way to handle this situation. I want to store
What is the best way to handle this situation on an iPhone device: My
What's the best way to handle translations for stock text in a SSRS .
What is the best way to handle a big team that has access to

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.