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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:26:10+00:00 2026-06-13T20:26:10+00:00

I have an outer div that is bound to a view model with ProcessClick

  • 0

I have an outer div that is bound to a view model with ProcessClick function and an inner div that is at runtime is bound to a different view model, but with the same function name for click. For some reason only an outer model’s function also gets called before an inner VM’s function does.

Markup:

<div id="max-outer">
   <span data-bind="click: BindInner">Bind Inner</span>
    <br/>
    <br/>
   <span data-bind="click: ProcessClick">Outer</span>
   <div id="max-inner">
      <span data-bind="click: ProcessClick">Inner</span>
       <br/>
   </div>
</div>

JS:

function InnderModel() {
    self = this;

    self.ProcessClick = function () 
        {
            alert("Inner clicked");
        };
}

function OuterModel() {
    self = this;

    self.ProcessClick = function (){
            alert("Outer clicked");
        };

    self.BindInner = function () {
        ko.cleanNode(document.getElementById("max-inner"));
        ko.applyBindings(new InnderModel(), document.getElementById("max-inner"));
    };
}

ko.applyBindings(new OuterModel(), document.getElementById("max-outer"));

Here is a fiddle:
http://jsfiddle.net/mpavlov/H2ZnV/8/

An idea is that clicking Bind inner and the clicking on Inner span would only show “Inner Clicked” alert, not both. Can this be achieved somehow?

  • 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-13T20:26:11+00:00Added an answer on June 13, 2026 at 8:26 pm

    The inner span will get bound the first time that applyBindings is called.

    Calling ko.cleanNode does not actually remove any event handlers, so it will still have the original handler.

    One technique that you could use is described in this tip on knockmeout.net.

    This allows you to identify an area that you want Knockout to skip binding.

    You would add a simple custom binding on your section that you don’t want to be bound originally:

    ko.bindingHandlers.stopBinding = {
        init: function() {
            return { controlsDescendantBindings: true };
        }
    };
    

    Would be as shown in this fiddle.

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

Sidebar

Related Questions

I have an outer div that is 800px wide. I have an inner div
I have an outer div, and inside of that, I have an inner div
I have two divs, one inner and one outer, but the inner div is
I have outer div and inner div. I need to place inner div at
I'm creating a horizontal menu bar. There is an outer div that contains inner
I have a div ( .outer - the viewport) with fixed height that contains
I have a div that contains another div. If the user clicks the inner
I have the following: <div class=outer style=margin-bottom: 10px> <div class=dialog-float> <select name=AccountID id=AccountID> ...
[CONFIRMED: IE9 suffers the same bug! :'( ] I have a div that is
I have one div inside another. The inner div is larger than the outer

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.