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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:47:51+00:00 2026-06-17T01:47:51+00:00

I am using RPNiemeyer`s kendo-knockout library. I have two nested bindings. I am using

  • 0

I am using RPNiemeyer`s kendo-knockout library. I have two nested bindings. I am using the preventBindings technique from here:

http://www.knockmeout.net/2012/05/quick-tip-skip-binding.html

I am applying bindings on the parent div and then prevent bindings on the nested div. When I click the row in the grid I expect the second bindings to be triggered and pop up to be opened but nothing happends. The example code is similar to the code in : Kendo-Knockout: widget observable is not filled with the actual widget

Only html is different (languageDetails div is nested into languageList div):

<div data-viewId="languageList">
  <div id="languageList" data-bind="with: viewModel">
    <div id="languageListGrid" data-bind="kendoGrid: { data: languageViewModels, columns: [ 
                { 
                    template: '<a href=\'\' data-bind=\'click: function() { onLanguageSelected(&quot;#=Language#&quot;) }\'>#=Language#</a>', 
                    field: 'Language', 
                    title: 'Language',
                    width: 50
                }

                ], 
            scrollable: false, sortable: true, pageable: false }, preventBinding: true"
    style="height: 380px"></div>
    <div data-bind="preventBinding: true">
      <div data-viewid="languageDetails">
        <div id="languageDetails" data-bind="with: viewModel" class="hidden">
          <form id="languageDetailsForm" action="" style="font-family: Trebuchet MS, Verdana, Helvetica, Sans-Serif;">
              <div data-bind="kendoWindow: {isOpen: isOpen, title:'Language', width: 400, height: 200, modal: true, widget: popUpWindow }">test
                  <button id="cancelLanguage" class="k-button" data-bind="click: cancelLanguage">Cancel</button>
              </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>

When I debug the code in my application when the bindings are applied on the languageList div and I click on the row to open the pop up the second bindings are not applied and the execution does not go into the function:

if (!elementIsBoundNew(element)) {
      var parentViewModel = {
        viewModel: viewModel
      };

Which maybe means that the first apply bindings has been applied on the two nested divs and the second prevent bindings has not worked. This is only my suggestion.

Here is the fiddle:

http://jsfiddle.net/PVMjy/4/

Any help will be greatly appreciated. Thanks!

Update per RP Niemeyer’s comment:

Your solution works for the sample i gave in fiddle, but does not work for my application. In my real scenario I use the selectedLanguage from the grid to find a language viewmodel from a list of existing viewmodels and assign it to selectedLanguageViewModel observable. In other words selectedLanguageViewModel is never empty. This is the code from my real application:

LanguageListViewModel.prototype.onLanguageSelected = function (selectedLanguage) {
            var languageViewModel = getLanguageViewModel(selectedLanguage);
            self.selectedLanguageViewModel(languageViewModel);
            utils.applyBindings(self.selectedLanguageViewModel, languageDetailsElement);
            self.selectedLanguageViewModel().openPopUp(false);
            //createTreeView();
        };

What I did here to make it work is save the div`s elementids I bound to in an array. Then, when I have to apply bindings, I check to see if the element is in the array and it if it is not then I apply bindings:

var applyedBindingsElements = [];

  var applyBindings = function (viewModel, elementId) {
    if($.inArray(elementId, applyedBindingsElements) == -1)
    {
      var element = $('div[data-viewId="' + elementId + '"]')[0];
      var parentViewModel = { viewModel: viewModel };
      ko.applyBindings(parentViewModel, element);

      applyedBindingsElements.push(elementId);
    }
  };

My future plans are to use languageList as a separate component that can appear several times on a same page. Then, this solution will not work as the div elementIds I bind the two components to, will have the same name ("languageList"). So I will have to think of some other solution then. But this is a topic of another question I will ask in the near future and will be gratefull to have your feedback on it. Thanks!

Working fiddle with my solution on this topic:

http://jsfiddle.net/PVMjy/6/

  • 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-17T01:47:53+00:00Added an answer on June 17, 2026 at 1:47 am

    The issue is that ko.dataFor searches up the DOM to find its value. So, it actually goes outside the area that had bindings skipped and finds the overall view model. So, your guard for whether bindings have already been applied is hit when trying to open the popup.

    I made some minor changes to get rid of the bindings check and just apply bindings to the popup area the first time that the button is clicked.

    Basically just this code after removing the already bound check:

    self.onLanguageSelected = function (selectedLanguage) {
      if (!self.selectedLanguageViewModel()) {
          applyBindings(self.selectedLanguageViewModel, "languageDetails");
      }
    
      self.selectedLanguageViewModel(self.languageViewModels()[0]);
      self.selectedLanguageViewModel().openPopUp();
    };
    

    Sample: http://jsfiddle.net/rniemeyer/8hzzn/

    Does this work for you?

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

Sidebar

Related Questions

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 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 three view models that instantiate each
Using the http://www.ifans.com/forums/showthread.php?t=132024 post from another question i am allowing the user to enter
Using CMake I want to check if a particular function (cv::getGaborKernel) from OpenCV library
I populated the Kendo Combox using KnockoutJS. I am using Knockout-Kendo.js to do that.
Using Maven build system under eclipse. I have just switched by project from using
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question

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.