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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:42:42+00:00 2026-06-16T05:42:42+00:00

I am using RPNiemeyer kendo-knockout library. I have three view models that instantiate each

  • 0

I am using RPNiemeyer kendo-knockout library. I have three view models that instantiate each other – FranchiseDetailsViewModel instantiates LanguageListViewModel which instantiates LanguageDetailsViewModel. The last viewmodel LanguageDetailsViewModel needs to have a reference to the parent FranchiseDetailsViewModel as its functionality depends on it.

html:

<div data-viewId="languageList" >
    <div id="languageList" data-bind="with: viewModel">
        <div id="languageListGrid" data-bind="kendoGrid: { data: languageViewModels, columns: [ 
                { 
                    field: 'Language', 
                    title: 'Language',
                    width: 50
                }

                ], 
            scrollable: false, sortable: true, pageable: false }" style="height: 380px">

        </div>
    </div>
</div>​

javascript

$(function () {

    var FranchiseDetailsViewModel = function () {
        var 
            self = this,
            initialize = function () {
                self.languagesInfoViewModel(new LanguageListViewModel(self));
                var parentViewModel = ({ viewModel: self.languagesInfoViewModel });
                var element = $('div[data-viewId="languageList"')[0];
                ko.applyBindings(parentViewModel, element);
            };

        FranchiseDetailsViewModel.prototype.languagesInfoViewModel = ko.observable();
        initialize();
    };

    var LanguageListViewModel = function (franchise) {
        var 
            self = this,
            initialize = function () {
                var languageViewModel = new LanguageDetailsViewModel(franchise);
                self.languageViewModels.push(languageViewModel);
            };
        LanguageListViewModel.prototype.languageViewModels = ko.observableArray([]);
        initialize();
    };

    var LanguageDetailsViewModel = function (franchise) {
        LanguageDetailsViewModel.prototype.Language = ko.observable("English");
       LanguageDetailsViewModel.prototype.franchise = franchise;
    };

    var initialize = new FranchiseDetailsViewModel();
});​

This reference to the parent view model causes some kind of a infinitive loop when the grid is binding to the source data. I am receiving Maximum call stack size exceeded error. I believe the error is in the kendo knockout library when binding to the source of the grid because if I remove the grid there are no errors on the knockout binding to the div on this line:

ko.applyBindings(parentViewModel, element);

Is this the real reason for this error and how can I fix this? I cannot remove the reference to the parent view model so my hope is to fix the kendo-knockout behavior when binding to the source data. Any help with working example will be greatly appreciated. Thanks.

http://jsfiddle.net/5Zkyg/43/

Update per Niemeyer`s comment:

I have a div with some properties bound to FranchiseDetailsViewModel. One of these properties represents a checkbox – name it isVisible. I have another div with properties bound to LanguageDetailsViewModel. Some of these properties are visible only if the checkbox of the FranchiseDetailsViewModel is checked. That is franchise.isVisible is true. This is the reason I need the franchise reference.

I am rather new to javascript and maybe I do not use the prototype property correctly. As I am instantiating my viewmodels with the new keyword I found that when assigning it to the prototype they become public and are visible in the markup so I can bind them. From your example I see that this.myProperty also makes the property public. I am not sure if there is a difference in my scenario.

I decided to use this.myData.parent = parent; as a solution to my problem. Thank You very much for your feedback.

  • 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-16T05:42:43+00:00Added an answer on June 16, 2026 at 5:42 am

    Based on the comment above:

    One option is to “hide” franchise, so that Knockout doesn’t recursively try to unwrap it. You can do this by making it a property of a function or observable (which is a function).

    There are a few ways to do this:

    var Child = function(parent) {
    
        //use parent directly from the argument passed to the constructor. available as part of the closure.
        this.myHandler = function() {
            parent.log();
        };        
    
        this.myData = ko.observable();
    
        //reference as a sub-observable. you can bind against myData.parent, but it will disappear when doing ko.toJS/ko.toJSON
        this.myData.parent = parent;
    
    
        //similar to sub-observable.  hide the actual value behind an empty function.  It will not be found when doing ko.toJS/ko.toJSON.
        this.parent = function() { };
        this.parent.value = parent;  
    };
    

    Example here: jsfiddle.net/rniemeyer/uSpZB.

    Normally you would not want to put observables on the prototype, as they will be shared by all instances.

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

Sidebar

Related Questions

I am using RPNiemeyer`s Knockout-Kendo.js library. I have a kendoui tabstrip. I looked through
I am using RPNiemeyer`s kendo-knockout library. I have a kendo grid with a kendo
I am using RPNiemeyer kendo-knockout library. I have a grid. When the user clicks
I am using RPNiemeyer`s kendo-knockout library. I have a kendo window: HTML: <div data-bind=kendoWindow:
I am using RPNiemeyer`s kendo-knockout library. I have two nested bindings. I am using
I populated the Kendo Combox using KnockoutJS. I am using Knockout-Kendo.js to do that.
Using SSRS 2008 R2 I have a background process that dynamically generates RDL for
Using CRM 4, I have an entity form that contains a tab with an
Using the Qt library, is there a way to automatically update a QDateTimeEdit using
Using RestKit 0.10.1, I have objects served similar to this json format: {objects: [

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.