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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:23:32+00:00 2026-06-02T00:23:32+00:00

Have a look at this small example . <select data-bind=options: Days, optionsText: ‘title’></select> <input

  • 0

Have a look at this small example.

<select data-bind="options: Days, optionsText: 'title'"></select>
<input type="button" value="update" data-bind="click: update" />

<script type="text/javascript">
var Days = {'Days': [{"id":1,"title":"Monday"},{"id":2,"title":"Tuesday"},{"id":3,"title":"Wensday"}]};

var DaysUpdate = {'Days': [{"id":3,"title":"Wednesday"},{"id":4,"title":"Thursday"},{"id":5,"title":"Friday"}]};

var mapping = {    
    'Days': {        
        key: function(data) {            
            return ko.utils.unwrapObservable(data.id);        
        }    
}}

var viewModel = {
    Days: ko.observableArray(),
    update: function() {
        ko.mapping.fromJS(DaysUpdate, mapping, viewModel);
    }
}

ko.mapping.fromJS(Days, mapping, viewModel);


ko.applyBindings(viewModel);

</script>

In this example data is mapped partially. First from Days object, then (by clicking update button) from DaysUpdate object. The the second update removes “Monday” and “Tuesday” objects from the array. How do I make those stay?

PS. Thanks to Mark Robinson for better structured example.

  • 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-06-02T00:23:33+00:00Added an answer on June 2, 2026 at 12:23 am

    This is a common question re the mapping plugin. Currently there is no way to do this with the plugin itself. It’s been a bugging me for a while. The plugin assumes that the array you gave it is the new contents of the array so removes the other items.

    The only solution I know of at present is to loop through the collection and manually map each element.

    http://jsfiddle.net/madcapnmckay/5878E/

    One of these days I’ll get around to trying to come up with a proper solution and send a pull request to the mapping plugin guys.

    Hope this helps.

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

Sidebar

Related Questions

Have a look a this simple example. I don't quite understand why o1 prints
I have a problem with internet explorer 6 and 7, please look this example
Have a look at this picture alt text http://www.abbeylegal.com/downloads/2009-04-01/web%20part%20top%20line.jpg Does anyone know what css
Have a look at this jsfiddle: http://jsfiddle.net/Dh96F/1/ The Expand button will animate the widening
Please have a look at this form that I am trying to design with
Please have a look at this page www.pixeli.ca/issue. I have begun making a page
Please have a look at this demo page that I cooked up a while
Please have a look at this validation array in my cakephp app for model
I have cells that look like this, one per line: Duffy,John: 'Heritage: Civilization and
i have a markup which look like this: <h3>Paragraf3-dummytext</h3> <p> <a name=paragraf3> Quisque id

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.