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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:41:56+00:00 2026-06-08T00:41:56+00:00

I’m retuning a JSON object from a web service and using knockout 2.01 to

  • 0

I’m retuning a JSON object from a web service and using knockout 2.01 to display the results. I’m able to display my results without an issue but as soon as I try to add a computed observable into the view model I get the error below.

What am I missing with this code below?

Uncaught TypeError: Object # has no method ‘dateCreated’

!— JSON

{"jobTitle":"Digital designer","dateCreated":"7/7/2012","timeCreated":"2:27    PM","location":"Perth","jobSummary":"one\ntwo\nthree","Uri":"/candidates/view-all-jobs/digital-designer/","CreateDate":"\/Date(1341635236000)\/"}

!– html

<div data-bind="foreach: $data">
 <article>
    <header>
      <time datetime="2007-08-29T13:58Z"></time>
      <h3><a target="_self" data-bind="text: $data.location"> </a> </h3>
    </header>
    <span data-bind="text: $data.fullDate">  </span> </article>
 </div> 

!– code

var viewModel = ko.observableArray();

$(document).ready(function () {
    if ($('#featured-jobs').length > 0) {
        $.ajax({

            type: 'POST',

            url: "handler/jobServer.ashx",

            data: { 'jobType': '1' },

            success: OnComplete,

            error: OnFail,

            dataType: 'json'
        });
    }
});



function OnComplete(result) {

    var self = this;
    ko.mapping.fromJS(result, {}, viewModel);

    self.fullDate = ko.computed(
  function () {
     return self.dateCreated() + " " + self.timeCreated();
  }, self); 

    ko.applyBindings(new viewModel());

}

function OnFail(result) {

    alert('Request Failed');

}
  • 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-08T00:41:59+00:00Added an answer on June 8, 2026 at 12:41 am

    It’s because onComplete creates a new object called self which doesn’t have a dateCreated Property. I think what you really want is to add that computed observable to every item in that viewModel.

    Edit:

    Observables are awesome, but sometimes they’re not the answer (especially if a value is not likely to change, like I suspect is the case for “created date” and “created time”). Here’s how I would do it (without observables). Note, you can still bind to non-observable properties:

    function OnComplete(result) {
    
        for (var i = 0; i < result.length; i++)
        {
            result[i].fullDate = result[i].dateCreated + " " + result[i].timeCreated;
        }
    
        viewModel(result);
        ko.applyBindings(viewModel);
    }
    

    If I’m wrong, and the user will be manipulating these values, you can do it like this (with observables):

    function OnComplete(result) {
    
        ko.mapping.fromJS(result, {}, viewModel);
    
        for (var i = 0; i < viewModel.length; i++)
        {
            viewModel[i].fullDate = ko.computed(
                function () {
                    return this.dateCreated() + " " + this.timeCreated();
                }, viewModel[i]); 
        }
    
        ko.applyBindings(viewModel);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
Seemingly simple, but I cannot find anything relevant on the web. What is the
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into

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.