javascript - Knockout.js mapping database data to multiple objects -


I am trying to load data into two JavaScript objects that I created using Knockout.js but I Actually it does not know how it is.

Currently, I have the following objects:

  function session (data) {this.id = data.id; This.class_id = data.class_id; This.user_id = data.user_id; // User objectives need to be answered. Stored_elapsed = data.stored_elapsed; } Function user (data) {this.id = data.id; This.first = data.first; This.last = data.last; }  

Thereafter, my view model for loading my data is:

  function session vivodel () {// data itself = it ; Self.sessions = ko.observableArray ([]); // Load data $ .getJSON ("/ session / milllist", function (all data) {var mapped sessions = $ .map (all data, functions (items) {return new session (item)) // session in user Objects are needed;); Self. Sessions (mapped sessions)}); } Ko.applyBindings (new session model ());  

This session works to create an object, but how can I create part of the session objects as a user object?


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -