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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:22:48+00:00 2026-06-10T07:22:48+00:00

On initial page load, my data gets loaded fine. I have a delete function

  • 0

On initial page load, my data gets loaded fine. I have a delete function which calls my controller through .ajax and deletes the item in the database OK, and then sends back the new list of JSON items. Everything works until I call ko.mapping.fromJS(data.newData, viewModel) and then the page just stalls out with no error messages. If I add in an alert(data.newData) I see the correct Json. Following is the code, can anyone see what I am doing wrong?

<script>
var initialData = @Html.Raw(Json.Encode(Model));

var viewModel = {
    trainingDocs : ko.observableArray(initialData)
};

function deleteDoc(doc) {
    $.ajax({
        url: "/Admin/_DeleteTrainingDocument/"+doc.TrainingDocumentId,
        type: "POST",
        data: "",
        success: function (data) {
            if (data.Result) {
                $("#userMessage").html("<img src='/content/Status_1.png' align='bottom' />" + data.Message);
                ko.mapping.fromJS(data.newData, viewModel);
            } else {
                $("#userMessage").html("<img src='/content/Status_0.png' align='bottom' />" + data.Message);
            }
        },
        error: function (jqXhr, textStatus, errorThrown) {
            alert("Error '" + jqXhr.status + "' (textStatus: '" + textStatus + "', errorThrown: '" + errorThrown + "')");
        },
        complete: function () {
        }
    });
};

ko.applyBindings(viewModel, document.body);
</script>

<table class="agent-info">
<thead>
    <tr> 
        <th>Title</th> 
        <th>Action</th> 
    </tr> 
</thead>
<tbody data-bind="foreach: trainingDocs">
    <tr> 
        <td><span data-bind="text:Title"></span></td> 
        <td><a href="#" id="whiteLinks" data-bind="click: function() { if(confirm('Are you sure you want to delete '+$data.Title+'?')) deleteDoc($data) }">delete</a></td>
    </tr> 
</tbody>
</table>​
<div id="userMessage">
    Results
</div>
  • 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-10T07:22:50+00:00Added an answer on June 10, 2026 at 7:22 am

    I am not sure of the exact structure being returned from your AJAX call, but if to update your existing data you either need to:

    • create your original observableArray using the mapping plugin like:

      var viewModel = {
      trainingDocs : ko.mapping.fromJS(initialData)
      };

    • or pass in empty mapping options when updating in your callback like:

      ko.mapping.fromJS(data.newData, {}, viewModel);

    Also, for the update call, I would pay close attention to what data.newData contains, because I would suspect that you may need to use viewModel.trainingDocs instead of just viewModel, if the data is the actual array.

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

Sidebar

Related Questions

I have a <ul> that is populated with javascript after the initial page load.
I have a simple ASP.NET page where after the initial page load the user
I have some javascript in a repeater item which calls AC_FL_RunContent to load and
I am working on a mobile app and I have an initial page that
currently I have a web which loads excel spreadsheet data into SQL database. When
Our initial page load is a beast in our Rails app. The great thing
I have an asp.net-mvc site. I have a page with a grid of data
I am creating an asp.net page which loads data from a (SQL) visual studio
I have a simple page which allows users to add language ids to items.
The user requests 2 rooms on the initial page and is then presented with

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.