Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Adding an anonymous object type to an observable array
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Rob L  
View profile  
 More options Nov 19 2012, 4:31 pm
From: Rob L <lebow...@finaltouch.com>
Date: Mon, 19 Nov 2012 13:31:10 -0800 (PST)
Local: Mon, Nov 19 2012 4:31 pm
Subject: Adding an anonymous object type to an observable array

I'm working on a simple application using MVC4 that allows me to display
each individual item in an observable array to the end user, and then
provides basic CRUD functionality such that a user can add, edit or delete
items.  

I create my observable array in the following manner:

  function Ob ligorViewModel() {    
   var obligorArray = ko.utils.parseJson('@jsonModel');
        self.obligors = ko.mapping.fromJS(obligorArray, mapping);

   this.selectedObligor = ko.observable();

    this.removeObligor = function (obligor) {
            self.obligors.remove(obligor);
        },
   this.editObligor = function (obligor) {
            self.selectedProduct(obligor);
        };
        this.addObligor = function () {
            self.selectedObligor(new ??());
        },

   ... etc.

}

I'm trying to figure out if it's possible to instantiate a new instance of
the obligor element without having to define a viewmodel for that object
type.  It seems to be possible to edit or delete anonyous object types
using the datafor or contextFor helper methods in KO, but I haven't been
able to determine if there is a manner in which you can instantiate a new
anonymous type.

I'm primarily trying to avoid having to define an obligor viewmodel in
JavaScript as well as in C# (this is an MVC4 application) so I can avoid
issues where the C# definition is changed but the JavaScript definition is
not.  

Any help would be appreciated.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »